{
 "cells": [
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "# Mouse-to-Human alignment\n",
    "\n",
    "- This notebook creates the alignments between human and mouse that can then be used to check whether the concordant mutation in mouse can be modeled.\n"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 1,
   "metadata": {},
   "outputs": [
    {
     "name": "stderr",
     "output_type": "stream",
     "text": [
      "/Users/samgould/anaconda3/lib/python3.7/site-packages/pandas/compat/_optional.py:138: UserWarning: Pandas requires version '2.7.0' or newer of 'numexpr' (version '2.6.8' currently installed).\n",
      "  warnings.warn(msg, UserWarning)\n"
     ]
    }
   ],
   "source": [
    "import numpy as np\n",
    "import matplotlib.pyplot as plt\n",
    "import pandas as pd\n",
    "import csv\n",
    "from Bio import SeqIO\n",
    "import gzip\n",
    "from Bio.Seq import Seq\n",
    "import re\n",
    "import gffutils"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 2,
   "metadata": {},
   "outputs": [],
   "source": [
    "pd.set_option('display.max_columns', 50)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 3,
   "metadata": {},
   "outputs": [
    {
     "name": "stderr",
     "output_type": "stream",
     "text": [
      "/Users/samgould/anaconda3/lib/python3.7/site-packages/IPython/core/interactiveshell.py:3267: DtypeWarning: Columns (45,48,88) have mixed types.Specify dtype option on import or set low_memory=False.\n",
      "  exec(code_obj, self.user_global_ns, self.user_ns)\n"
     ]
    },
    {
     "data": {
      "text/html": [
       "<div>\n",
       "<style scoped>\n",
       "    .dataframe tbody tr th:only-of-type {\n",
       "        vertical-align: middle;\n",
       "    }\n",
       "\n",
       "    .dataframe tbody tr th {\n",
       "        vertical-align: top;\n",
       "    }\n",
       "\n",
       "    .dataframe thead th {\n",
       "        text-align: right;\n",
       "    }\n",
       "</style>\n",
       "<table border=\"1\" class=\"dataframe\">\n",
       "  <thead>\n",
       "    <tr style=\"text-align: right;\">\n",
       "      <th></th>\n",
       "      <th>Hugo_Symbol</th>\n",
       "      <th>Entrez_Gene_Id</th>\n",
       "      <th>Center</th>\n",
       "      <th>NCBI_Build</th>\n",
       "      <th>Chromosome</th>\n",
       "      <th>Start_Position</th>\n",
       "      <th>End_Position</th>\n",
       "      <th>Strand</th>\n",
       "      <th>Consequence</th>\n",
       "      <th>Variant_Classification</th>\n",
       "      <th>Variant_Type</th>\n",
       "      <th>Reference_Allele</th>\n",
       "      <th>Tumor_Seq_Allele1</th>\n",
       "      <th>Tumor_Seq_Allele2</th>\n",
       "      <th>dbSNP_RS</th>\n",
       "      <th>dbSNP_Val_Status</th>\n",
       "      <th>Tumor_Sample_Barcode</th>\n",
       "      <th>Matched_Norm_Sample_Barcode</th>\n",
       "      <th>Match_Norm_Seq_Allele1</th>\n",
       "      <th>Match_Norm_Seq_Allele2</th>\n",
       "      <th>Tumor_Validation_Allele1</th>\n",
       "      <th>Tumor_Validation_Allele2</th>\n",
       "      <th>Match_Norm_Validation_Allele1</th>\n",
       "      <th>Match_Norm_Validation_Allele2</th>\n",
       "      <th>Verification_Status</th>\n",
       "      <th>...</th>\n",
       "      <th>MOTIF_SCORE_CHANGE</th>\n",
       "      <th>PHENO</th>\n",
       "      <th>PICK</th>\n",
       "      <th>PUBMED</th>\n",
       "      <th>PolyPhen</th>\n",
       "      <th>SAS_MAF</th>\n",
       "      <th>SIFT</th>\n",
       "      <th>SOMATIC</th>\n",
       "      <th>SWISSPROT</th>\n",
       "      <th>SYMBOL</th>\n",
       "      <th>SYMBOL_SOURCE</th>\n",
       "      <th>TREMBL</th>\n",
       "      <th>TSL</th>\n",
       "      <th>Transcript</th>\n",
       "      <th>UNIPARC</th>\n",
       "      <th>VARIANT_CLASS</th>\n",
       "      <th>all_effects</th>\n",
       "      <th>amino_acid_change</th>\n",
       "      <th>cDNA_Change</th>\n",
       "      <th>cDNA_position</th>\n",
       "      <th>cdna_change</th>\n",
       "      <th>comments</th>\n",
       "      <th>n_depth</th>\n",
       "      <th>t_depth</th>\n",
       "      <th>transcript</th>\n",
       "    </tr>\n",
       "  </thead>\n",
       "  <tbody>\n",
       "    <tr>\n",
       "      <th>0</th>\n",
       "      <td>BRCA2</td>\n",
       "      <td>675</td>\n",
       "      <td>MSKCC</td>\n",
       "      <td>GRCh37</td>\n",
       "      <td>13</td>\n",
       "      <td>32937315</td>\n",
       "      <td>32937315</td>\n",
       "      <td>+</td>\n",
       "      <td>splice_acceptor_variant</td>\n",
       "      <td>Splice_Site</td>\n",
       "      <td>SNP</td>\n",
       "      <td>G</td>\n",
       "      <td>G</td>\n",
       "      <td>C</td>\n",
       "      <td>rs81002874</td>\n",
       "      <td>NaN</td>\n",
       "      <td>P-0029279-T01-IM6</td>\n",
       "      <td>NaN</td>\n",
       "      <td>NaN</td>\n",
       "      <td>NaN</td>\n",
       "      <td>NaN</td>\n",
       "      <td>NaN</td>\n",
       "      <td>NaN</td>\n",
       "      <td>NaN</td>\n",
       "      <td>NaN</td>\n",
       "      <td>...</td>\n",
       "      <td>NaN</td>\n",
       "      <td>NaN</td>\n",
       "      <td>NaN</td>\n",
       "      <td>NaN</td>\n",
       "      <td>NaN</td>\n",
       "      <td>NaN</td>\n",
       "      <td>NaN</td>\n",
       "      <td>NaN</td>\n",
       "      <td>NaN</td>\n",
       "      <td>NaN</td>\n",
       "      <td>NaN</td>\n",
       "      <td>NaN</td>\n",
       "      <td>NaN</td>\n",
       "      <td>NaN</td>\n",
       "      <td>NaN</td>\n",
       "      <td>NaN</td>\n",
       "      <td>NaN</td>\n",
       "      <td>NaN</td>\n",
       "      <td>NaN</td>\n",
       "      <td>NaN</td>\n",
       "      <td>NaN</td>\n",
       "      <td>NaN</td>\n",
       "      <td>NaN</td>\n",
       "      <td>NaN</td>\n",
       "      <td>NaN</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>1</th>\n",
       "      <td>BRCA2</td>\n",
       "      <td>0</td>\n",
       "      <td>MSKCC</td>\n",
       "      <td>37</td>\n",
       "      <td>13</td>\n",
       "      <td>32914437</td>\n",
       "      <td>32914438</td>\n",
       "      <td>+</td>\n",
       "      <td>NaN</td>\n",
       "      <td>NaN</td>\n",
       "      <td>DEL</td>\n",
       "      <td>GT</td>\n",
       "      <td>GT</td>\n",
       "      <td>G</td>\n",
       "      <td>rs80359550</td>\n",
       "      <td>NaN</td>\n",
       "      <td>P-0034227-T01-IM6</td>\n",
       "      <td>NaN</td>\n",
       "      <td>NaN</td>\n",
       "      <td>NaN</td>\n",
       "      <td>NaN</td>\n",
       "      <td>NaN</td>\n",
       "      <td>NaN</td>\n",
       "      <td>NaN</td>\n",
       "      <td>NaN</td>\n",
       "      <td>...</td>\n",
       "      <td>NaN</td>\n",
       "      <td>NaN</td>\n",
       "      <td>NaN</td>\n",
       "      <td>NaN</td>\n",
       "      <td>NaN</td>\n",
       "      <td>NaN</td>\n",
       "      <td>NaN</td>\n",
       "      <td>NaN</td>\n",
       "      <td>NaN</td>\n",
       "      <td>NaN</td>\n",
       "      <td>NaN</td>\n",
       "      <td>NaN</td>\n",
       "      <td>NaN</td>\n",
       "      <td>NaN</td>\n",
       "      <td>NaN</td>\n",
       "      <td>NaN</td>\n",
       "      <td>NaN</td>\n",
       "      <td>NaN</td>\n",
       "      <td>NaN</td>\n",
       "      <td>NaN</td>\n",
       "      <td>NaN</td>\n",
       "      <td>NaN</td>\n",
       "      <td>NaN</td>\n",
       "      <td>NaN</td>\n",
       "      <td>NaN</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>2</th>\n",
       "      <td>MUTYH</td>\n",
       "      <td>4595</td>\n",
       "      <td>MSKCC</td>\n",
       "      <td>GRCh37</td>\n",
       "      <td>1</td>\n",
       "      <td>45798475</td>\n",
       "      <td>45798475</td>\n",
       "      <td>+</td>\n",
       "      <td>missense_variant</td>\n",
       "      <td>Missense_Mutation</td>\n",
       "      <td>SNP</td>\n",
       "      <td>T</td>\n",
       "      <td>T</td>\n",
       "      <td>C</td>\n",
       "      <td>rs34612342</td>\n",
       "      <td>NaN</td>\n",
       "      <td>P-0030735-T01-IM6</td>\n",
       "      <td>NaN</td>\n",
       "      <td>NaN</td>\n",
       "      <td>NaN</td>\n",
       "      <td>NaN</td>\n",
       "      <td>NaN</td>\n",
       "      <td>NaN</td>\n",
       "      <td>NaN</td>\n",
       "      <td>NaN</td>\n",
       "      <td>...</td>\n",
       "      <td>NaN</td>\n",
       "      <td>NaN</td>\n",
       "      <td>NaN</td>\n",
       "      <td>NaN</td>\n",
       "      <td>NaN</td>\n",
       "      <td>NaN</td>\n",
       "      <td>NaN</td>\n",
       "      <td>NaN</td>\n",
       "      <td>NaN</td>\n",
       "      <td>NaN</td>\n",
       "      <td>NaN</td>\n",
       "      <td>NaN</td>\n",
       "      <td>NaN</td>\n",
       "      <td>NaN</td>\n",
       "      <td>NaN</td>\n",
       "      <td>NaN</td>\n",
       "      <td>NaN</td>\n",
       "      <td>NaN</td>\n",
       "      <td>NaN</td>\n",
       "      <td>NaN</td>\n",
       "      <td>NaN</td>\n",
       "      <td>NaN</td>\n",
       "      <td>NaN</td>\n",
       "      <td>NaN</td>\n",
       "      <td>NaN</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>3</th>\n",
       "      <td>BRCA2</td>\n",
       "      <td>675</td>\n",
       "      <td>MSKCC</td>\n",
       "      <td>GRCh37</td>\n",
       "      <td>13</td>\n",
       "      <td>32893302</td>\n",
       "      <td>32893302</td>\n",
       "      <td>+</td>\n",
       "      <td>frameshift_variant</td>\n",
       "      <td>Frame_Shift_Ins</td>\n",
       "      <td>INS</td>\n",
       "      <td>T</td>\n",
       "      <td>T</td>\n",
       "      <td>GCCGGGCGCGGTGG</td>\n",
       "      <td>NaN</td>\n",
       "      <td>NaN</td>\n",
       "      <td>P-0038798-T01-IM6</td>\n",
       "      <td>NaN</td>\n",
       "      <td>NaN</td>\n",
       "      <td>NaN</td>\n",
       "      <td>NaN</td>\n",
       "      <td>NaN</td>\n",
       "      <td>NaN</td>\n",
       "      <td>NaN</td>\n",
       "      <td>NaN</td>\n",
       "      <td>...</td>\n",
       "      <td>NaN</td>\n",
       "      <td>NaN</td>\n",
       "      <td>NaN</td>\n",
       "      <td>NaN</td>\n",
       "      <td>NaN</td>\n",
       "      <td>NaN</td>\n",
       "      <td>NaN</td>\n",
       "      <td>NaN</td>\n",
       "      <td>NaN</td>\n",
       "      <td>NaN</td>\n",
       "      <td>NaN</td>\n",
       "      <td>NaN</td>\n",
       "      <td>NaN</td>\n",
       "      <td>NaN</td>\n",
       "      <td>NaN</td>\n",
       "      <td>NaN</td>\n",
       "      <td>NaN</td>\n",
       "      <td>NaN</td>\n",
       "      <td>NaN</td>\n",
       "      <td>NaN</td>\n",
       "      <td>NaN</td>\n",
       "      <td>NaN</td>\n",
       "      <td>NaN</td>\n",
       "      <td>NaN</td>\n",
       "      <td>NaN</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>4</th>\n",
       "      <td>BRCA1</td>\n",
       "      <td>0</td>\n",
       "      <td>MSKCC</td>\n",
       "      <td>37</td>\n",
       "      <td>17</td>\n",
       "      <td>41251824</td>\n",
       "      <td>41251825</td>\n",
       "      <td>+</td>\n",
       "      <td>NaN</td>\n",
       "      <td>NaN</td>\n",
       "      <td>DEL</td>\n",
       "      <td>TG</td>\n",
       "      <td>TG</td>\n",
       "      <td>T</td>\n",
       "      <td>rs80357872</td>\n",
       "      <td>NaN</td>\n",
       "      <td>P-0030162-T01-IM6</td>\n",
       "      <td>NaN</td>\n",
       "      <td>NaN</td>\n",
       "      <td>NaN</td>\n",
       "      <td>NaN</td>\n",
       "      <td>NaN</td>\n",
       "      <td>NaN</td>\n",
       "      <td>NaN</td>\n",
       "      <td>NaN</td>\n",
       "      <td>...</td>\n",
       "      <td>NaN</td>\n",
       "      <td>NaN</td>\n",
       "      <td>NaN</td>\n",
       "      <td>NaN</td>\n",
       "      <td>NaN</td>\n",
       "      <td>NaN</td>\n",
       "      <td>NaN</td>\n",
       "      <td>NaN</td>\n",
       "      <td>NaN</td>\n",
       "      <td>NaN</td>\n",
       "      <td>NaN</td>\n",
       "      <td>NaN</td>\n",
       "      <td>NaN</td>\n",
       "      <td>NaN</td>\n",
       "      <td>NaN</td>\n",
       "      <td>NaN</td>\n",
       "      <td>NaN</td>\n",
       "      <td>NaN</td>\n",
       "      <td>NaN</td>\n",
       "      <td>NaN</td>\n",
       "      <td>NaN</td>\n",
       "      <td>NaN</td>\n",
       "      <td>NaN</td>\n",
       "      <td>NaN</td>\n",
       "      <td>NaN</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>...</th>\n",
       "      <td>...</td>\n",
       "      <td>...</td>\n",
       "      <td>...</td>\n",
       "      <td>...</td>\n",
       "      <td>...</td>\n",
       "      <td>...</td>\n",
       "      <td>...</td>\n",
       "      <td>...</td>\n",
       "      <td>...</td>\n",
       "      <td>...</td>\n",
       "      <td>...</td>\n",
       "      <td>...</td>\n",
       "      <td>...</td>\n",
       "      <td>...</td>\n",
       "      <td>...</td>\n",
       "      <td>...</td>\n",
       "      <td>...</td>\n",
       "      <td>...</td>\n",
       "      <td>...</td>\n",
       "      <td>...</td>\n",
       "      <td>...</td>\n",
       "      <td>...</td>\n",
       "      <td>...</td>\n",
       "      <td>...</td>\n",
       "      <td>...</td>\n",
       "      <td>...</td>\n",
       "      <td>...</td>\n",
       "      <td>...</td>\n",
       "      <td>...</td>\n",
       "      <td>...</td>\n",
       "      <td>...</td>\n",
       "      <td>...</td>\n",
       "      <td>...</td>\n",
       "      <td>...</td>\n",
       "      <td>...</td>\n",
       "      <td>...</td>\n",
       "      <td>...</td>\n",
       "      <td>...</td>\n",
       "      <td>...</td>\n",
       "      <td>...</td>\n",
       "      <td>...</td>\n",
       "      <td>...</td>\n",
       "      <td>...</td>\n",
       "      <td>...</td>\n",
       "      <td>...</td>\n",
       "      <td>...</td>\n",
       "      <td>...</td>\n",
       "      <td>...</td>\n",
       "      <td>...</td>\n",
       "      <td>...</td>\n",
       "      <td>...</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>422817</th>\n",
       "      <td>SMARCA4</td>\n",
       "      <td>6597</td>\n",
       "      <td>MSKCC</td>\n",
       "      <td>GRCh37</td>\n",
       "      <td>19</td>\n",
       "      <td>11144132</td>\n",
       "      <td>11144132</td>\n",
       "      <td>+</td>\n",
       "      <td>missense_variant</td>\n",
       "      <td>Missense_Mutation</td>\n",
       "      <td>SNP</td>\n",
       "      <td>C</td>\n",
       "      <td>C</td>\n",
       "      <td>G</td>\n",
       "      <td>NaN</td>\n",
       "      <td>NaN</td>\n",
       "      <td>P-0052864-T01-XS1</td>\n",
       "      <td>NaN</td>\n",
       "      <td>NaN</td>\n",
       "      <td>NaN</td>\n",
       "      <td>NaN</td>\n",
       "      <td>NaN</td>\n",
       "      <td>NaN</td>\n",
       "      <td>NaN</td>\n",
       "      <td>NaN</td>\n",
       "      <td>...</td>\n",
       "      <td>NaN</td>\n",
       "      <td>NaN</td>\n",
       "      <td>NaN</td>\n",
       "      <td>NaN</td>\n",
       "      <td>NaN</td>\n",
       "      <td>NaN</td>\n",
       "      <td>NaN</td>\n",
       "      <td>NaN</td>\n",
       "      <td>NaN</td>\n",
       "      <td>NaN</td>\n",
       "      <td>NaN</td>\n",
       "      <td>NaN</td>\n",
       "      <td>NaN</td>\n",
       "      <td>NaN</td>\n",
       "      <td>NaN</td>\n",
       "      <td>NaN</td>\n",
       "      <td>NaN</td>\n",
       "      <td>NaN</td>\n",
       "      <td>NaN</td>\n",
       "      <td>NaN</td>\n",
       "      <td>NaN</td>\n",
       "      <td>NaN</td>\n",
       "      <td>NaN</td>\n",
       "      <td>NaN</td>\n",
       "      <td>NaN</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>422818</th>\n",
       "      <td>BRAF</td>\n",
       "      <td>673</td>\n",
       "      <td>MSKCC</td>\n",
       "      <td>GRCh37</td>\n",
       "      <td>7</td>\n",
       "      <td>140453149</td>\n",
       "      <td>140453149</td>\n",
       "      <td>+</td>\n",
       "      <td>missense_variant</td>\n",
       "      <td>Missense_Mutation</td>\n",
       "      <td>SNP</td>\n",
       "      <td>C</td>\n",
       "      <td>C</td>\n",
       "      <td>G</td>\n",
       "      <td>rs121913361</td>\n",
       "      <td>NaN</td>\n",
       "      <td>P-0052867-T01-XS1</td>\n",
       "      <td>NaN</td>\n",
       "      <td>NaN</td>\n",
       "      <td>NaN</td>\n",
       "      <td>NaN</td>\n",
       "      <td>NaN</td>\n",
       "      <td>NaN</td>\n",
       "      <td>NaN</td>\n",
       "      <td>NaN</td>\n",
       "      <td>...</td>\n",
       "      <td>NaN</td>\n",
       "      <td>NaN</td>\n",
       "      <td>NaN</td>\n",
       "      <td>NaN</td>\n",
       "      <td>NaN</td>\n",
       "      <td>NaN</td>\n",
       "      <td>NaN</td>\n",
       "      <td>NaN</td>\n",
       "      <td>NaN</td>\n",
       "      <td>NaN</td>\n",
       "      <td>NaN</td>\n",
       "      <td>NaN</td>\n",
       "      <td>NaN</td>\n",
       "      <td>NaN</td>\n",
       "      <td>NaN</td>\n",
       "      <td>NaN</td>\n",
       "      <td>NaN</td>\n",
       "      <td>NaN</td>\n",
       "      <td>NaN</td>\n",
       "      <td>NaN</td>\n",
       "      <td>NaN</td>\n",
       "      <td>NaN</td>\n",
       "      <td>NaN</td>\n",
       "      <td>NaN</td>\n",
       "      <td>NaN</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>422819</th>\n",
       "      <td>NRAS</td>\n",
       "      <td>4893</td>\n",
       "      <td>MSKCC</td>\n",
       "      <td>GRCh37</td>\n",
       "      <td>1</td>\n",
       "      <td>115258747</td>\n",
       "      <td>115258747</td>\n",
       "      <td>+</td>\n",
       "      <td>missense_variant</td>\n",
       "      <td>Missense_Mutation</td>\n",
       "      <td>SNP</td>\n",
       "      <td>C</td>\n",
       "      <td>C</td>\n",
       "      <td>T</td>\n",
       "      <td>rs121913237</td>\n",
       "      <td>NaN</td>\n",
       "      <td>P-0052951-T01-XS1</td>\n",
       "      <td>NaN</td>\n",
       "      <td>NaN</td>\n",
       "      <td>NaN</td>\n",
       "      <td>NaN</td>\n",
       "      <td>NaN</td>\n",
       "      <td>NaN</td>\n",
       "      <td>NaN</td>\n",
       "      <td>NaN</td>\n",
       "      <td>...</td>\n",
       "      <td>NaN</td>\n",
       "      <td>NaN</td>\n",
       "      <td>NaN</td>\n",
       "      <td>NaN</td>\n",
       "      <td>NaN</td>\n",
       "      <td>NaN</td>\n",
       "      <td>NaN</td>\n",
       "      <td>NaN</td>\n",
       "      <td>NaN</td>\n",
       "      <td>NaN</td>\n",
       "      <td>NaN</td>\n",
       "      <td>NaN</td>\n",
       "      <td>NaN</td>\n",
       "      <td>NaN</td>\n",
       "      <td>NaN</td>\n",
       "      <td>NaN</td>\n",
       "      <td>NaN</td>\n",
       "      <td>NaN</td>\n",
       "      <td>NaN</td>\n",
       "      <td>NaN</td>\n",
       "      <td>NaN</td>\n",
       "      <td>NaN</td>\n",
       "      <td>NaN</td>\n",
       "      <td>NaN</td>\n",
       "      <td>NaN</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>422820</th>\n",
       "      <td>TERT</td>\n",
       "      <td>7015</td>\n",
       "      <td>MSKCC</td>\n",
       "      <td>GRCh37</td>\n",
       "      <td>5</td>\n",
       "      <td>1295521</td>\n",
       "      <td>1295521</td>\n",
       "      <td>+</td>\n",
       "      <td>upstream_gene_variant</td>\n",
       "      <td>5'Flank</td>\n",
       "      <td>SNP</td>\n",
       "      <td>A</td>\n",
       "      <td>A</td>\n",
       "      <td>T</td>\n",
       "      <td>NaN</td>\n",
       "      <td>NaN</td>\n",
       "      <td>P-0052951-T01-XS1</td>\n",
       "      <td>NaN</td>\n",
       "      <td>NaN</td>\n",
       "      <td>NaN</td>\n",
       "      <td>NaN</td>\n",
       "      <td>NaN</td>\n",
       "      <td>NaN</td>\n",
       "      <td>NaN</td>\n",
       "      <td>NaN</td>\n",
       "      <td>...</td>\n",
       "      <td>NaN</td>\n",
       "      <td>NaN</td>\n",
       "      <td>NaN</td>\n",
       "      <td>NaN</td>\n",
       "      <td>NaN</td>\n",
       "      <td>NaN</td>\n",
       "      <td>NaN</td>\n",
       "      <td>NaN</td>\n",
       "      <td>NaN</td>\n",
       "      <td>NaN</td>\n",
       "      <td>NaN</td>\n",
       "      <td>NaN</td>\n",
       "      <td>NaN</td>\n",
       "      <td>NaN</td>\n",
       "      <td>NaN</td>\n",
       "      <td>NaN</td>\n",
       "      <td>NaN</td>\n",
       "      <td>NaN</td>\n",
       "      <td>NaN</td>\n",
       "      <td>NaN</td>\n",
       "      <td>NaN</td>\n",
       "      <td>NaN</td>\n",
       "      <td>NaN</td>\n",
       "      <td>NaN</td>\n",
       "      <td>NaN</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>422821</th>\n",
       "      <td>KRAS</td>\n",
       "      <td>3845</td>\n",
       "      <td>MSKCC</td>\n",
       "      <td>GRCh37</td>\n",
       "      <td>12</td>\n",
       "      <td>25398284</td>\n",
       "      <td>25398284</td>\n",
       "      <td>+</td>\n",
       "      <td>missense_variant</td>\n",
       "      <td>Missense_Mutation</td>\n",
       "      <td>SNP</td>\n",
       "      <td>C</td>\n",
       "      <td>C</td>\n",
       "      <td>A</td>\n",
       "      <td>NaN</td>\n",
       "      <td>NaN</td>\n",
       "      <td>P-0052952-T01-XS1</td>\n",
       "      <td>NaN</td>\n",
       "      <td>NaN</td>\n",
       "      <td>NaN</td>\n",
       "      <td>NaN</td>\n",
       "      <td>NaN</td>\n",
       "      <td>NaN</td>\n",
       "      <td>NaN</td>\n",
       "      <td>NaN</td>\n",
       "      <td>...</td>\n",
       "      <td>NaN</td>\n",
       "      <td>NaN</td>\n",
       "      <td>NaN</td>\n",
       "      <td>NaN</td>\n",
       "      <td>NaN</td>\n",
       "      <td>NaN</td>\n",
       "      <td>NaN</td>\n",
       "      <td>NaN</td>\n",
       "      <td>NaN</td>\n",
       "      <td>NaN</td>\n",
       "      <td>NaN</td>\n",
       "      <td>NaN</td>\n",
       "      <td>NaN</td>\n",
       "      <td>NaN</td>\n",
       "      <td>NaN</td>\n",
       "      <td>NaN</td>\n",
       "      <td>NaN</td>\n",
       "      <td>NaN</td>\n",
       "      <td>NaN</td>\n",
       "      <td>NaN</td>\n",
       "      <td>NaN</td>\n",
       "      <td>NaN</td>\n",
       "      <td>NaN</td>\n",
       "      <td>NaN</td>\n",
       "      <td>NaN</td>\n",
       "    </tr>\n",
       "  </tbody>\n",
       "</table>\n",
       "<p>422822 rows × 123 columns</p>\n",
       "</div>"
      ],
      "text/plain": [
       "       Hugo_Symbol  Entrez_Gene_Id Center NCBI_Build Chromosome  \\\n",
       "0            BRCA2             675  MSKCC     GRCh37         13   \n",
       "1            BRCA2               0  MSKCC         37         13   \n",
       "2            MUTYH            4595  MSKCC     GRCh37          1   \n",
       "3            BRCA2             675  MSKCC     GRCh37         13   \n",
       "4            BRCA1               0  MSKCC         37         17   \n",
       "...            ...             ...    ...        ...        ...   \n",
       "422817     SMARCA4            6597  MSKCC     GRCh37         19   \n",
       "422818        BRAF             673  MSKCC     GRCh37          7   \n",
       "422819        NRAS            4893  MSKCC     GRCh37          1   \n",
       "422820        TERT            7015  MSKCC     GRCh37          5   \n",
       "422821        KRAS            3845  MSKCC     GRCh37         12   \n",
       "\n",
       "        Start_Position  End_Position Strand              Consequence  \\\n",
       "0             32937315      32937315      +  splice_acceptor_variant   \n",
       "1             32914437      32914438      +                      NaN   \n",
       "2             45798475      45798475      +         missense_variant   \n",
       "3             32893302      32893302      +       frameshift_variant   \n",
       "4             41251824      41251825      +                      NaN   \n",
       "...                ...           ...    ...                      ...   \n",
       "422817        11144132      11144132      +         missense_variant   \n",
       "422818       140453149     140453149      +         missense_variant   \n",
       "422819       115258747     115258747      +         missense_variant   \n",
       "422820         1295521       1295521      +    upstream_gene_variant   \n",
       "422821        25398284      25398284      +         missense_variant   \n",
       "\n",
       "       Variant_Classification Variant_Type Reference_Allele Tumor_Seq_Allele1  \\\n",
       "0                 Splice_Site          SNP                G                 G   \n",
       "1                         NaN          DEL               GT                GT   \n",
       "2           Missense_Mutation          SNP                T                 T   \n",
       "3             Frame_Shift_Ins          INS                T                 T   \n",
       "4                         NaN          DEL               TG                TG   \n",
       "...                       ...          ...              ...               ...   \n",
       "422817      Missense_Mutation          SNP                C                 C   \n",
       "422818      Missense_Mutation          SNP                C                 C   \n",
       "422819      Missense_Mutation          SNP                C                 C   \n",
       "422820                5'Flank          SNP                A                 A   \n",
       "422821      Missense_Mutation          SNP                C                 C   \n",
       "\n",
       "       Tumor_Seq_Allele2     dbSNP_RS  dbSNP_Val_Status Tumor_Sample_Barcode  \\\n",
       "0                      C   rs81002874               NaN    P-0029279-T01-IM6   \n",
       "1                      G   rs80359550               NaN    P-0034227-T01-IM6   \n",
       "2                      C   rs34612342               NaN    P-0030735-T01-IM6   \n",
       "3         GCCGGGCGCGGTGG          NaN               NaN    P-0038798-T01-IM6   \n",
       "4                      T   rs80357872               NaN    P-0030162-T01-IM6   \n",
       "...                  ...          ...               ...                  ...   \n",
       "422817                 G          NaN               NaN    P-0052864-T01-XS1   \n",
       "422818                 G  rs121913361               NaN    P-0052867-T01-XS1   \n",
       "422819                 T  rs121913237               NaN    P-0052951-T01-XS1   \n",
       "422820                 T          NaN               NaN    P-0052951-T01-XS1   \n",
       "422821                 A          NaN               NaN    P-0052952-T01-XS1   \n",
       "\n",
       "        Matched_Norm_Sample_Barcode  Match_Norm_Seq_Allele1  \\\n",
       "0                               NaN                     NaN   \n",
       "1                               NaN                     NaN   \n",
       "2                               NaN                     NaN   \n",
       "3                               NaN                     NaN   \n",
       "4                               NaN                     NaN   \n",
       "...                             ...                     ...   \n",
       "422817                          NaN                     NaN   \n",
       "422818                          NaN                     NaN   \n",
       "422819                          NaN                     NaN   \n",
       "422820                          NaN                     NaN   \n",
       "422821                          NaN                     NaN   \n",
       "\n",
       "        Match_Norm_Seq_Allele2  Tumor_Validation_Allele1  \\\n",
       "0                          NaN                       NaN   \n",
       "1                          NaN                       NaN   \n",
       "2                          NaN                       NaN   \n",
       "3                          NaN                       NaN   \n",
       "4                          NaN                       NaN   \n",
       "...                        ...                       ...   \n",
       "422817                     NaN                       NaN   \n",
       "422818                     NaN                       NaN   \n",
       "422819                     NaN                       NaN   \n",
       "422820                     NaN                       NaN   \n",
       "422821                     NaN                       NaN   \n",
       "\n",
       "        Tumor_Validation_Allele2  Match_Norm_Validation_Allele1  \\\n",
       "0                            NaN                            NaN   \n",
       "1                            NaN                            NaN   \n",
       "2                            NaN                            NaN   \n",
       "3                            NaN                            NaN   \n",
       "4                            NaN                            NaN   \n",
       "...                          ...                            ...   \n",
       "422817                       NaN                            NaN   \n",
       "422818                       NaN                            NaN   \n",
       "422819                       NaN                            NaN   \n",
       "422820                       NaN                            NaN   \n",
       "422821                       NaN                            NaN   \n",
       "\n",
       "        Match_Norm_Validation_Allele2  Verification_Status  ...  \\\n",
       "0                                 NaN                  NaN  ...   \n",
       "1                                 NaN                  NaN  ...   \n",
       "2                                 NaN                  NaN  ...   \n",
       "3                                 NaN                  NaN  ...   \n",
       "4                                 NaN                  NaN  ...   \n",
       "...                               ...                  ...  ...   \n",
       "422817                            NaN                  NaN  ...   \n",
       "422818                            NaN                  NaN  ...   \n",
       "422819                            NaN                  NaN  ...   \n",
       "422820                            NaN                  NaN  ...   \n",
       "422821                            NaN                  NaN  ...   \n",
       "\n",
       "       MOTIF_SCORE_CHANGE PHENO  PICK  PUBMED  PolyPhen SAS_MAF  SIFT  \\\n",
       "0                     NaN   NaN   NaN     NaN       NaN     NaN   NaN   \n",
       "1                     NaN   NaN   NaN     NaN       NaN     NaN   NaN   \n",
       "2                     NaN   NaN   NaN     NaN       NaN     NaN   NaN   \n",
       "3                     NaN   NaN   NaN     NaN       NaN     NaN   NaN   \n",
       "4                     NaN   NaN   NaN     NaN       NaN     NaN   NaN   \n",
       "...                   ...   ...   ...     ...       ...     ...   ...   \n",
       "422817                NaN   NaN   NaN     NaN       NaN     NaN   NaN   \n",
       "422818                NaN   NaN   NaN     NaN       NaN     NaN   NaN   \n",
       "422819                NaN   NaN   NaN     NaN       NaN     NaN   NaN   \n",
       "422820                NaN   NaN   NaN     NaN       NaN     NaN   NaN   \n",
       "422821                NaN   NaN   NaN     NaN       NaN     NaN   NaN   \n",
       "\n",
       "        SOMATIC  SWISSPROT  SYMBOL  SYMBOL_SOURCE  TREMBL TSL Transcript  \\\n",
       "0           NaN        NaN     NaN            NaN     NaN NaN        NaN   \n",
       "1           NaN        NaN     NaN            NaN     NaN NaN        NaN   \n",
       "2           NaN        NaN     NaN            NaN     NaN NaN        NaN   \n",
       "3           NaN        NaN     NaN            NaN     NaN NaN        NaN   \n",
       "4           NaN        NaN     NaN            NaN     NaN NaN        NaN   \n",
       "...         ...        ...     ...            ...     ...  ..        ...   \n",
       "422817      NaN        NaN     NaN            NaN     NaN NaN        NaN   \n",
       "422818      NaN        NaN     NaN            NaN     NaN NaN        NaN   \n",
       "422819      NaN        NaN     NaN            NaN     NaN NaN        NaN   \n",
       "422820      NaN        NaN     NaN            NaN     NaN NaN        NaN   \n",
       "422821      NaN        NaN     NaN            NaN     NaN NaN        NaN   \n",
       "\n",
       "       UNIPARC VARIANT_CLASS all_effects  amino_acid_change cDNA_Change  \\\n",
       "0          NaN           NaN         NaN                NaN         NaN   \n",
       "1          NaN           NaN         NaN                NaN         NaN   \n",
       "2          NaN           NaN         NaN                NaN         NaN   \n",
       "3          NaN           NaN         NaN                NaN         NaN   \n",
       "4          NaN           NaN         NaN                NaN         NaN   \n",
       "...        ...           ...         ...                ...         ...   \n",
       "422817     NaN           NaN         NaN                NaN         NaN   \n",
       "422818     NaN           NaN         NaN                NaN         NaN   \n",
       "422819     NaN           NaN         NaN                NaN         NaN   \n",
       "422820     NaN           NaN         NaN                NaN         NaN   \n",
       "422821     NaN           NaN         NaN                NaN         NaN   \n",
       "\n",
       "        cDNA_position cdna_change  comments  n_depth t_depth  transcript  \n",
       "0                 NaN         NaN       NaN      NaN     NaN         NaN  \n",
       "1                 NaN         NaN       NaN      NaN     NaN         NaN  \n",
       "2                 NaN         NaN       NaN      NaN     NaN         NaN  \n",
       "3                 NaN         NaN       NaN      NaN     NaN         NaN  \n",
       "4                 NaN         NaN       NaN      NaN     NaN         NaN  \n",
       "...               ...         ...       ...      ...     ...         ...  \n",
       "422817            NaN         NaN       NaN      NaN     NaN         NaN  \n",
       "422818            NaN         NaN       NaN      NaN     NaN         NaN  \n",
       "422819            NaN         NaN       NaN      NaN     NaN         NaN  \n",
       "422820            NaN         NaN       NaN      NaN     NaN         NaN  \n",
       "422821            NaN         NaN       NaN      NaN     NaN         NaN  \n",
       "\n",
       "[422822 rows x 123 columns]"
      ]
     },
     "execution_count": 3,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "filepath = '/Volumes/Sam_G_SSD/2020-06-16-MSK-IMPACT_EDITED.txt'\n",
    "impact_data = pd.read_csv(filepath, sep='\\t')\n",
    "impact_data"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 4,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/html": [
       "<div>\n",
       "<style scoped>\n",
       "    .dataframe tbody tr th:only-of-type {\n",
       "        vertical-align: middle;\n",
       "    }\n",
       "\n",
       "    .dataframe tbody tr th {\n",
       "        vertical-align: top;\n",
       "    }\n",
       "\n",
       "    .dataframe thead th {\n",
       "        text-align: right;\n",
       "    }\n",
       "</style>\n",
       "<table border=\"1\" class=\"dataframe\">\n",
       "  <thead>\n",
       "    <tr style=\"text-align: right;\">\n",
       "      <th></th>\n",
       "      <th>gene</th>\n",
       "      <th>human gene name</th>\n",
       "      <th>mouse gene name</th>\n",
       "      <th>mouse id</th>\n",
       "      <th>mouse id version</th>\n",
       "      <th>mouse transcript</th>\n",
       "    </tr>\n",
       "  </thead>\n",
       "  <tbody>\n",
       "    <tr>\n",
       "      <th>0</th>\n",
       "      <td>ABL1</td>\n",
       "      <td>ABL1</td>\n",
       "      <td>Abl1</td>\n",
       "      <td>ENSMUSG00000026842</td>\n",
       "      <td>ENSMUSG00000026842.16</td>\n",
       "      <td>ENSMUST00000028190.12</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>1</th>\n",
       "      <td>AC004906.3</td>\n",
       "      <td>NONE</td>\n",
       "      <td>NONE</td>\n",
       "      <td>NONE</td>\n",
       "      <td>NONE</td>\n",
       "      <td>NONE</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>2</th>\n",
       "      <td>AC008738.1</td>\n",
       "      <td>NONE</td>\n",
       "      <td>NONE</td>\n",
       "      <td>NONE</td>\n",
       "      <td>NONE</td>\n",
       "      <td>NONE</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>3</th>\n",
       "      <td>ACTG1</td>\n",
       "      <td>ACTG1</td>\n",
       "      <td>Actg1</td>\n",
       "      <td>ENSMUSG00000062825</td>\n",
       "      <td>ENSMUSG00000062825.15</td>\n",
       "      <td>ENSMUST00000071555.12</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>4</th>\n",
       "      <td>ACVR1</td>\n",
       "      <td>ACVR1</td>\n",
       "      <td>Acvr1</td>\n",
       "      <td>ENSMUSG00000026836</td>\n",
       "      <td>ENSMUSG00000026836.15</td>\n",
       "      <td>ENSMUST00000056376.11</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>...</th>\n",
       "      <td>...</td>\n",
       "      <td>...</td>\n",
       "      <td>...</td>\n",
       "      <td>...</td>\n",
       "      <td>...</td>\n",
       "      <td>...</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>589</th>\n",
       "      <td>XRCC2</td>\n",
       "      <td>XRCC2</td>\n",
       "      <td>Xrcc2</td>\n",
       "      <td>ENSMUSG00000028933</td>\n",
       "      <td>ENSMUSG00000028933.11</td>\n",
       "      <td>ENSMUST00000030773.11</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>590</th>\n",
       "      <td>YAP1</td>\n",
       "      <td>YAP1</td>\n",
       "      <td>Yap1</td>\n",
       "      <td>ENSMUSG00000053110</td>\n",
       "      <td>ENSMUSG00000053110.13</td>\n",
       "      <td>ENSMUST00000086580.11</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>591</th>\n",
       "      <td>YES1</td>\n",
       "      <td>YES1</td>\n",
       "      <td>Yes1</td>\n",
       "      <td>ENSMUSG00000014932</td>\n",
       "      <td>ENSMUSG00000014932.15</td>\n",
       "      <td>ENSMUST00000168707.5</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>592</th>\n",
       "      <td>ZFHX3</td>\n",
       "      <td>ZFHX3</td>\n",
       "      <td>Zfhx3</td>\n",
       "      <td>ENSMUSG00000038872</td>\n",
       "      <td>ENSMUSG00000038872.10</td>\n",
       "      <td>ENSMUST00000043896.9</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>593</th>\n",
       "      <td>ZRSR2</td>\n",
       "      <td>ZRSR2</td>\n",
       "      <td>Zrsr1</td>\n",
       "      <td>ENSMUSG00000044068</td>\n",
       "      <td>ENSMUSG00000044068.7</td>\n",
       "      <td>ENSMUST00000049506.7</td>\n",
       "    </tr>\n",
       "  </tbody>\n",
       "</table>\n",
       "<p>594 rows × 6 columns</p>\n",
       "</div>"
      ],
      "text/plain": [
       "           gene human gene name mouse gene name            mouse id  \\\n",
       "0          ABL1            ABL1            Abl1  ENSMUSG00000026842   \n",
       "1    AC004906.3            NONE            NONE                NONE   \n",
       "2    AC008738.1            NONE            NONE                NONE   \n",
       "3         ACTG1           ACTG1           Actg1  ENSMUSG00000062825   \n",
       "4         ACVR1           ACVR1           Acvr1  ENSMUSG00000026836   \n",
       "..          ...             ...             ...                 ...   \n",
       "589       XRCC2           XRCC2           Xrcc2  ENSMUSG00000028933   \n",
       "590        YAP1            YAP1            Yap1  ENSMUSG00000053110   \n",
       "591        YES1            YES1            Yes1  ENSMUSG00000014932   \n",
       "592       ZFHX3           ZFHX3           Zfhx3  ENSMUSG00000038872   \n",
       "593       ZRSR2           ZRSR2           Zrsr1  ENSMUSG00000044068   \n",
       "\n",
       "          mouse id version       mouse transcript  \n",
       "0    ENSMUSG00000026842.16  ENSMUST00000028190.12  \n",
       "1                     NONE                   NONE  \n",
       "2                     NONE                   NONE  \n",
       "3    ENSMUSG00000062825.15  ENSMUST00000071555.12  \n",
       "4    ENSMUSG00000026836.15  ENSMUST00000056376.11  \n",
       "..                     ...                    ...  \n",
       "589  ENSMUSG00000028933.11  ENSMUST00000030773.11  \n",
       "590  ENSMUSG00000053110.13  ENSMUST00000086580.11  \n",
       "591  ENSMUSG00000014932.15   ENSMUST00000168707.5  \n",
       "592  ENSMUSG00000038872.10   ENSMUST00000043896.9  \n",
       "593   ENSMUSG00000044068.7   ENSMUST00000049506.7  \n",
       "\n",
       "[594 rows x 6 columns]"
      ]
     },
     "execution_count": 4,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "#homology dataframe\n",
    "\n",
    "homology_df = np.load('/Volumes/Sam_G_SSD/homology_table.npy', allow_pickle=True)\n",
    "homology_df = pd.DataFrame(homology_df,columns=['gene','human gene name','mouse gene name','mouse id','mouse id version','mouse transcript'])\n",
    "\n",
    "homology_df"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 5,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/html": [
       "<div>\n",
       "<style scoped>\n",
       "    .dataframe tbody tr th:only-of-type {\n",
       "        vertical-align: middle;\n",
       "    }\n",
       "\n",
       "    .dataframe tbody tr th {\n",
       "        vertical-align: top;\n",
       "    }\n",
       "\n",
       "    .dataframe thead th {\n",
       "        text-align: right;\n",
       "    }\n",
       "</style>\n",
       "<table border=\"1\" class=\"dataframe\">\n",
       "  <thead>\n",
       "    <tr style=\"text-align: right;\">\n",
       "      <th></th>\n",
       "      <th>gene</th>\n",
       "      <th>gene_id</th>\n",
       "      <th>transcript_id</th>\n",
       "      <th>chrom</th>\n",
       "      <th>gene_start</th>\n",
       "      <th>gene_end</th>\n",
       "      <th>transcript_start</th>\n",
       "      <th>transcript_end</th>\n",
       "      <th>strand</th>\n",
       "    </tr>\n",
       "  </thead>\n",
       "  <tbody>\n",
       "    <tr>\n",
       "      <th>0</th>\n",
       "      <td>ABL1</td>\n",
       "      <td>ENSG00000097007.13</td>\n",
       "      <td>ENST00000318560.5</td>\n",
       "      <td>chr9</td>\n",
       "      <td>133589333</td>\n",
       "      <td>133763062</td>\n",
       "      <td>133710453</td>\n",
       "      <td>133763062</td>\n",
       "      <td>+</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>1</th>\n",
       "      <td>AC004906.3</td>\n",
       "      <td>ENSG00000237286.1</td>\n",
       "      <td>ENST00000423194.1</td>\n",
       "      <td>chr7</td>\n",
       "      <td>2983669</td>\n",
       "      <td>2986725</td>\n",
       "      <td>2983669</td>\n",
       "      <td>2986725</td>\n",
       "      <td>+</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>2</th>\n",
       "      <td>AC008738.1</td>\n",
       "      <td>ENSG00000230259.2</td>\n",
       "      <td>ENST00000425420.2</td>\n",
       "      <td>chr19</td>\n",
       "      <td>33790853</td>\n",
       "      <td>33793430</td>\n",
       "      <td>33790853</td>\n",
       "      <td>33793430</td>\n",
       "      <td>-</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>3</th>\n",
       "      <td>ACTG1</td>\n",
       "      <td>ENSG00000184009.5</td>\n",
       "      <td>ENST00000575842.1</td>\n",
       "      <td>chr17</td>\n",
       "      <td>79476997</td>\n",
       "      <td>79490873</td>\n",
       "      <td>79477015</td>\n",
       "      <td>79479807</td>\n",
       "      <td>-</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>4</th>\n",
       "      <td>ACVR1</td>\n",
       "      <td>ENSG00000115170.9</td>\n",
       "      <td>ENST00000263640.3</td>\n",
       "      <td>chr2</td>\n",
       "      <td>158592958</td>\n",
       "      <td>158732374</td>\n",
       "      <td>158592958</td>\n",
       "      <td>158731623</td>\n",
       "      <td>-</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>...</th>\n",
       "      <td>...</td>\n",
       "      <td>...</td>\n",
       "      <td>...</td>\n",
       "      <td>...</td>\n",
       "      <td>...</td>\n",
       "      <td>...</td>\n",
       "      <td>...</td>\n",
       "      <td>...</td>\n",
       "      <td>...</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>589</th>\n",
       "      <td>XRCC2</td>\n",
       "      <td>ENSG00000196584.2</td>\n",
       "      <td>ENST00000359321.1</td>\n",
       "      <td>chr7</td>\n",
       "      <td>152341864</td>\n",
       "      <td>152373250</td>\n",
       "      <td>152343589</td>\n",
       "      <td>152373250</td>\n",
       "      <td>-</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>590</th>\n",
       "      <td>YAP1</td>\n",
       "      <td>ENSG00000137693.9</td>\n",
       "      <td>ENST00000282441.5</td>\n",
       "      <td>chr11</td>\n",
       "      <td>101981192</td>\n",
       "      <td>102104154</td>\n",
       "      <td>101981192</td>\n",
       "      <td>102104154</td>\n",
       "      <td>+</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>591</th>\n",
       "      <td>YES1</td>\n",
       "      <td>ENSG00000176105.9</td>\n",
       "      <td>ENST00000314574.4</td>\n",
       "      <td>chr18</td>\n",
       "      <td>721588</td>\n",
       "      <td>812547</td>\n",
       "      <td>721748</td>\n",
       "      <td>812239</td>\n",
       "      <td>-</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>592</th>\n",
       "      <td>ZFHX3</td>\n",
       "      <td>ENSG00000140836.10</td>\n",
       "      <td>ENST00000268489.5</td>\n",
       "      <td>chr16</td>\n",
       "      <td>72816784</td>\n",
       "      <td>73093597</td>\n",
       "      <td>72816784</td>\n",
       "      <td>73082274</td>\n",
       "      <td>-</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>593</th>\n",
       "      <td>ZRSR2</td>\n",
       "      <td>ENSG00000169249.8</td>\n",
       "      <td>ENST00000307771.7</td>\n",
       "      <td>chrX</td>\n",
       "      <td>15808595</td>\n",
       "      <td>15841383</td>\n",
       "      <td>15808595</td>\n",
       "      <td>15841383</td>\n",
       "      <td>+</td>\n",
       "    </tr>\n",
       "  </tbody>\n",
       "</table>\n",
       "<p>594 rows × 9 columns</p>\n",
       "</div>"
      ],
      "text/plain": [
       "           gene             gene_id      transcript_id  chrom  gene_start  \\\n",
       "0          ABL1  ENSG00000097007.13  ENST00000318560.5   chr9   133589333   \n",
       "1    AC004906.3   ENSG00000237286.1  ENST00000423194.1   chr7     2983669   \n",
       "2    AC008738.1   ENSG00000230259.2  ENST00000425420.2  chr19    33790853   \n",
       "3         ACTG1   ENSG00000184009.5  ENST00000575842.1  chr17    79476997   \n",
       "4         ACVR1   ENSG00000115170.9  ENST00000263640.3   chr2   158592958   \n",
       "..          ...                 ...                ...    ...         ...   \n",
       "589       XRCC2   ENSG00000196584.2  ENST00000359321.1   chr7   152341864   \n",
       "590        YAP1   ENSG00000137693.9  ENST00000282441.5  chr11   101981192   \n",
       "591        YES1   ENSG00000176105.9  ENST00000314574.4  chr18      721588   \n",
       "592       ZFHX3  ENSG00000140836.10  ENST00000268489.5  chr16    72816784   \n",
       "593       ZRSR2   ENSG00000169249.8  ENST00000307771.7   chrX    15808595   \n",
       "\n",
       "      gene_end  transcript_start  transcript_end strand  \n",
       "0    133763062         133710453       133763062      +  \n",
       "1      2986725           2983669         2986725      +  \n",
       "2     33793430          33790853        33793430      -  \n",
       "3     79490873          79477015        79479807      -  \n",
       "4    158732374         158592958       158731623      -  \n",
       "..         ...               ...             ...    ...  \n",
       "589  152373250         152343589       152373250      -  \n",
       "590  102104154         101981192       102104154      +  \n",
       "591     812547            721748          812239      -  \n",
       "592   73093597          72816784        73082274      -  \n",
       "593   15841383          15808595        15841383      +  \n",
       "\n",
       "[594 rows x 9 columns]"
      ]
     },
     "execution_count": 5,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "filename1 = '/Users/samgould/Desktop/FSR Lab/2022-03-17/gene_info.csv'\n",
    "df1 = pd.read_csv(filename1)\n",
    "df1"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 16,
   "metadata": {},
   "outputs": [],
   "source": [
    "#loading in annotation databases for human and mouse\n",
    "file = '/Volumes/Sam_G_SSD/gencode_v19.db'\n",
    "db = gffutils.FeatureDB(file)\n",
    "\n",
    "file_mouse = '/Volumes/Sam_G_SSD/GRCm38.p6 (mouse)/gencode_vM25.db'\n",
    "db_mouse = gffutils.FeatureDB(file_mouse)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 6,
   "metadata": {
    "code_folding": []
   },
   "outputs": [],
   "source": [
    "#loading in necessary genes for human\n",
    "path = '/Volumes/Sam_G_SSD/human genome GrCh37 IMPACT genes/'\n",
    "impact_genes = np.load(path + 'human_impact_genes_plusminus5000.npy', allow_pickle=True)\n",
    "unique_genes = np.load(path + 'human_impact_genes_NAMES.npy', allow_pickle=True)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 18,
   "metadata": {},
   "outputs": [],
   "source": [
    "#loading in mouse genes\n",
    "#loading in necessary genes for human\n",
    "path = '/Volumes/Sam_G_SSD/mouse genome GRCm38.p6 IMPACT genes/'\n",
    "mouse_genes = np.load(path + 'mouse_impact_genes_plusminus5000.npy', allow_pickle=True)\n",
    "mouse_gene_names = np.load(path + 'mouse_impact_genes_NAMES.npy', allow_pickle=True)"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "# Generating human protein from transcript\n",
    "- Also has ability to model mutations of interest in transcript"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 230,
   "metadata": {},
   "outputs": [],
   "source": [
    "p53_idx = np.asarray(impact_data[impact_data['Hugo_Symbol']=='KRAS'].index)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 231,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/html": [
       "<div>\n",
       "<style scoped>\n",
       "    .dataframe tbody tr th:only-of-type {\n",
       "        vertical-align: middle;\n",
       "    }\n",
       "\n",
       "    .dataframe tbody tr th {\n",
       "        vertical-align: top;\n",
       "    }\n",
       "\n",
       "    .dataframe thead th {\n",
       "        text-align: right;\n",
       "    }\n",
       "</style>\n",
       "<table border=\"1\" class=\"dataframe\">\n",
       "  <thead>\n",
       "    <tr style=\"text-align: right;\">\n",
       "      <th></th>\n",
       "      <th>Hugo_Symbol</th>\n",
       "      <th>Entrez_Gene_Id</th>\n",
       "      <th>Center</th>\n",
       "      <th>NCBI_Build</th>\n",
       "      <th>Chromosome</th>\n",
       "      <th>Start_Position</th>\n",
       "      <th>End_Position</th>\n",
       "      <th>Strand</th>\n",
       "      <th>Consequence</th>\n",
       "      <th>Variant_Classification</th>\n",
       "      <th>...</th>\n",
       "      <th>VARIANT_CLASS</th>\n",
       "      <th>all_effects</th>\n",
       "      <th>amino_acid_change</th>\n",
       "      <th>cDNA_Change</th>\n",
       "      <th>cDNA_position</th>\n",
       "      <th>cdna_change</th>\n",
       "      <th>comments</th>\n",
       "      <th>n_depth</th>\n",
       "      <th>t_depth</th>\n",
       "      <th>transcript</th>\n",
       "    </tr>\n",
       "  </thead>\n",
       "  <tbody>\n",
       "    <tr>\n",
       "      <th>7764</th>\n",
       "      <td>KRAS</td>\n",
       "      <td>3845</td>\n",
       "      <td>MSKCC</td>\n",
       "      <td>GRCh37</td>\n",
       "      <td>12</td>\n",
       "      <td>25398281</td>\n",
       "      <td>25398281</td>\n",
       "      <td>+</td>\n",
       "      <td>missense_variant</td>\n",
       "      <td>Missense_Mutation</td>\n",
       "      <td>...</td>\n",
       "      <td>NaN</td>\n",
       "      <td>NaN</td>\n",
       "      <td>NaN</td>\n",
       "      <td>NaN</td>\n",
       "      <td>NaN</td>\n",
       "      <td>NaN</td>\n",
       "      <td>NaN</td>\n",
       "      <td>NaN</td>\n",
       "      <td>NaN</td>\n",
       "      <td>NaN</td>\n",
       "    </tr>\n",
       "  </tbody>\n",
       "</table>\n",
       "<p>1 rows × 123 columns</p>\n",
       "</div>"
      ],
      "text/plain": [
       "     Hugo_Symbol  Entrez_Gene_Id Center NCBI_Build Chromosome  Start_Position  \\\n",
       "7764        KRAS            3845  MSKCC     GRCh37         12        25398281   \n",
       "\n",
       "      End_Position Strand       Consequence Variant_Classification  ...  \\\n",
       "7764      25398281      +  missense_variant      Missense_Mutation  ...   \n",
       "\n",
       "     VARIANT_CLASS all_effects amino_acid_change cDNA_Change cDNA_position  \\\n",
       "7764           NaN         NaN               NaN         NaN           NaN   \n",
       "\n",
       "      cdna_change comments  n_depth  t_depth  transcript  \n",
       "7764          NaN      NaN      NaN      NaN         NaN  \n",
       "\n",
       "[1 rows x 123 columns]"
      ]
     },
     "execution_count": 231,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "idx = p53_idx[128]\n",
    "impact_data.iloc[[idx]]"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 233,
   "metadata": {},
   "outputs": [],
   "source": [
    "#now doing an example of a gene on the minus strand\n",
    "\n",
    "def human_protein(gene_name, unique_gene_list, tx_ids, SNP):\n",
    "    tx_idx = unique_gene_list.index(gene_name)\n",
    "    tx = tx_ids[tx_idx]\n",
    "\n",
    "    #always order by + strand and then deal with - end genes later on\n",
    "    cds = list(db.children(tx, order_by='+end', featuretype=['CDS'])) #only accessing cds\n",
    "    #CDS refers to all of the exons in the gene\n",
    "\n",
    "    #DEFINING the start and end of each coding exon\n",
    "    start_end_cds = [[i.start, i.end] for i in cds]\n",
    "\n",
    "\n",
    "    #23 = X\n",
    "    seq_list = []\n",
    "    for i in range(len(start_end_cds)):\n",
    "        #need to put it in the correct indexing frame for the loaded in genes\n",
    "        gene_start = df1[df1['gene']==gene_name]['gene_start'].values[0]\n",
    "        #gene_end = df1[df1['gene']==gene_name]['gene_end'].values[0]\n",
    "\n",
    "        start = start_end_cds[i][0]-1-gene_start+5000\n",
    "        end = start_end_cds[i][1]-gene_start+5000\n",
    "        sequence = impact_genes[tx_idx][start:end]\n",
    "\n",
    "        seq_list.append(sequence)\n",
    "\n",
    "    concatenated_seq = sum(seq_list, Seq(\"\"))\n",
    "\n",
    "    #take reverse complement to account for minus strand\n",
    "    strand = df1[df1['gene']==gene_name]['strand'].values[0]\n",
    "    if strand=='-': #if minus strand\n",
    "        seq_true = concatenated_seq.reverse_complement()\n",
    "    elif strand=='+':\n",
    "        seq_true = concatenated_seq\n",
    "\n",
    "\n",
    "    mRNA = seq_true.transcribe()\n",
    "    prot_seq = mRNA.translate()\n",
    "\n",
    "    #-_______________________________MUTATIONS_____________________________#\n",
    "    #information about mutation of interest\n",
    "    #FOR NOW ONLY LOOKING AT SNPs\n",
    "    snp = SNP\n",
    "\n",
    "    coding_location1 = impact_data.iloc[[idx]]['HGVSc'].values[0].split('.')[2]\n",
    "    coding_location = int(re.findall(r'\\d+', coding_location1)[0])\n",
    "\n",
    "    seq_mut = seq_true[0:coding_location-1] + snp + seq_true[coding_location:]\n",
    "    mRNA_mut = seq_mut.transcribe()\n",
    "    prot_seq_mut = mRNA_mut.translate()\n",
    "\n",
    "    \n",
    "    return mRNA, prot_seq, mRNA_mut, prot_seq_mut"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 234,
   "metadata": {},
   "outputs": [],
   "source": [
    "unique_gene_list = list(unique_genes)\n",
    "tx_ids = np.asarray(df1['transcript_id'])\n",
    "\n",
    "gene_name = 'KRAS'\n",
    "\n",
    "SNP = impact_data.iloc[[idx]]['HGVSc'].values[0][-1]\n",
    "#need to expand to other mutation types\n",
    "\n",
    "mRNA, prot_seq, mRNA_mut, prot_seq_mut = human_protein(gene_name, unique_gene_list, tx_ids, SNP)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 235,
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "p.Gly13Asp\n",
      "G\n",
      "D\n"
     ]
    }
   ],
   "source": [
    "#checking correctness\n",
    "print(impact_data.iloc[[idx]]['HGVSp'].values[0])\n",
    "idx_aa = int(re.findall(r'\\d+', impact_data.iloc[[idx]]['HGVSp'].values[0])[0])\n",
    "print(prot_seq[idx_aa-1])\n",
    "print(prot_seq_mut[idx_aa-1])"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "# Generating mouse protein sequence from transcript\n",
    "- Also has ability to model mutations of interest"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 237,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/html": [
       "<div>\n",
       "<style scoped>\n",
       "    .dataframe tbody tr th:only-of-type {\n",
       "        vertical-align: middle;\n",
       "    }\n",
       "\n",
       "    .dataframe tbody tr th {\n",
       "        vertical-align: top;\n",
       "    }\n",
       "\n",
       "    .dataframe thead th {\n",
       "        text-align: right;\n",
       "    }\n",
       "</style>\n",
       "<table border=\"1\" class=\"dataframe\">\n",
       "  <thead>\n",
       "    <tr style=\"text-align: right;\">\n",
       "      <th></th>\n",
       "      <th>gene</th>\n",
       "      <th>human gene name</th>\n",
       "      <th>mouse gene name</th>\n",
       "      <th>mouse id</th>\n",
       "      <th>mouse id version</th>\n",
       "      <th>mouse transcript</th>\n",
       "    </tr>\n",
       "  </thead>\n",
       "  <tbody>\n",
       "    <tr>\n",
       "      <th>0</th>\n",
       "      <td>ABL1</td>\n",
       "      <td>ABL1</td>\n",
       "      <td>Abl1</td>\n",
       "      <td>ENSMUSG00000026842</td>\n",
       "      <td>ENSMUSG00000026842.16</td>\n",
       "      <td>ENSMUST00000028190.12</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>1</th>\n",
       "      <td>AC004906.3</td>\n",
       "      <td>NONE</td>\n",
       "      <td>NONE</td>\n",
       "      <td>NONE</td>\n",
       "      <td>NONE</td>\n",
       "      <td>NONE</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>2</th>\n",
       "      <td>AC008738.1</td>\n",
       "      <td>NONE</td>\n",
       "      <td>NONE</td>\n",
       "      <td>NONE</td>\n",
       "      <td>NONE</td>\n",
       "      <td>NONE</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>3</th>\n",
       "      <td>ACTG1</td>\n",
       "      <td>ACTG1</td>\n",
       "      <td>Actg1</td>\n",
       "      <td>ENSMUSG00000062825</td>\n",
       "      <td>ENSMUSG00000062825.15</td>\n",
       "      <td>ENSMUST00000071555.12</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>4</th>\n",
       "      <td>ACVR1</td>\n",
       "      <td>ACVR1</td>\n",
       "      <td>Acvr1</td>\n",
       "      <td>ENSMUSG00000026836</td>\n",
       "      <td>ENSMUSG00000026836.15</td>\n",
       "      <td>ENSMUST00000056376.11</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>...</th>\n",
       "      <td>...</td>\n",
       "      <td>...</td>\n",
       "      <td>...</td>\n",
       "      <td>...</td>\n",
       "      <td>...</td>\n",
       "      <td>...</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>589</th>\n",
       "      <td>XRCC2</td>\n",
       "      <td>XRCC2</td>\n",
       "      <td>Xrcc2</td>\n",
       "      <td>ENSMUSG00000028933</td>\n",
       "      <td>ENSMUSG00000028933.11</td>\n",
       "      <td>ENSMUST00000030773.11</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>590</th>\n",
       "      <td>YAP1</td>\n",
       "      <td>YAP1</td>\n",
       "      <td>Yap1</td>\n",
       "      <td>ENSMUSG00000053110</td>\n",
       "      <td>ENSMUSG00000053110.13</td>\n",
       "      <td>ENSMUST00000086580.11</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>591</th>\n",
       "      <td>YES1</td>\n",
       "      <td>YES1</td>\n",
       "      <td>Yes1</td>\n",
       "      <td>ENSMUSG00000014932</td>\n",
       "      <td>ENSMUSG00000014932.15</td>\n",
       "      <td>ENSMUST00000168707.5</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>592</th>\n",
       "      <td>ZFHX3</td>\n",
       "      <td>ZFHX3</td>\n",
       "      <td>Zfhx3</td>\n",
       "      <td>ENSMUSG00000038872</td>\n",
       "      <td>ENSMUSG00000038872.10</td>\n",
       "      <td>ENSMUST00000043896.9</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>593</th>\n",
       "      <td>ZRSR2</td>\n",
       "      <td>ZRSR2</td>\n",
       "      <td>Zrsr1</td>\n",
       "      <td>ENSMUSG00000044068</td>\n",
       "      <td>ENSMUSG00000044068.7</td>\n",
       "      <td>ENSMUST00000049506.7</td>\n",
       "    </tr>\n",
       "  </tbody>\n",
       "</table>\n",
       "<p>594 rows × 6 columns</p>\n",
       "</div>"
      ],
      "text/plain": [
       "           gene human gene name mouse gene name            mouse id  \\\n",
       "0          ABL1            ABL1            Abl1  ENSMUSG00000026842   \n",
       "1    AC004906.3            NONE            NONE                NONE   \n",
       "2    AC008738.1            NONE            NONE                NONE   \n",
       "3         ACTG1           ACTG1           Actg1  ENSMUSG00000062825   \n",
       "4         ACVR1           ACVR1           Acvr1  ENSMUSG00000026836   \n",
       "..          ...             ...             ...                 ...   \n",
       "589       XRCC2           XRCC2           Xrcc2  ENSMUSG00000028933   \n",
       "590        YAP1            YAP1            Yap1  ENSMUSG00000053110   \n",
       "591        YES1            YES1            Yes1  ENSMUSG00000014932   \n",
       "592       ZFHX3           ZFHX3           Zfhx3  ENSMUSG00000038872   \n",
       "593       ZRSR2           ZRSR2           Zrsr1  ENSMUSG00000044068   \n",
       "\n",
       "          mouse id version       mouse transcript  \n",
       "0    ENSMUSG00000026842.16  ENSMUST00000028190.12  \n",
       "1                     NONE                   NONE  \n",
       "2                     NONE                   NONE  \n",
       "3    ENSMUSG00000062825.15  ENSMUST00000071555.12  \n",
       "4    ENSMUSG00000026836.15  ENSMUST00000056376.11  \n",
       "..                     ...                    ...  \n",
       "589  ENSMUSG00000028933.11  ENSMUST00000030773.11  \n",
       "590  ENSMUSG00000053110.13  ENSMUST00000086580.11  \n",
       "591  ENSMUSG00000014932.15   ENSMUST00000168707.5  \n",
       "592  ENSMUSG00000038872.10   ENSMUST00000043896.9  \n",
       "593   ENSMUSG00000044068.7   ENSMUST00000049506.7  \n",
       "\n",
       "[594 rows x 6 columns]"
      ]
     },
     "execution_count": 237,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "homology_df"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 238,
   "metadata": {},
   "outputs": [],
   "source": [
    "def mouse_protein(human_gene_name, mouse_genes, db_mouse, unique_gene_list):\n",
    "    \n",
    "    tx_idx = unique_gene_list.index(human_gene_name)\n",
    "    \n",
    "    gene_id = homology_df[homology_df['gene']==human_gene_name]['mouse id version'].values[0]\n",
    "    tx = homology_df[homology_df['gene']==human_gene_name]['mouse transcript'].values[0]\n",
    "\n",
    "\n",
    "    #always order by + strand and then deal with - end genes later on\n",
    "    cds = list(db_mouse.children(tx, order_by='+end', featuretype=['CDS'])) #only accessing cds\n",
    "    #CDS refers to all of the exons in the gene\n",
    "\n",
    "    #DEFINING the start and end of each coding exon\n",
    "    start_end_cds = [[i.start, i.end] for i in cds]\n",
    "\n",
    "    seq_list = []\n",
    "    for i in range(len(start_end_cds)):\n",
    "        #need to put it in the correct indexing frame for the loaded in genes\n",
    "        #gene_start = df1[df1['gene']==gene_name]['gene_start'].values[0]\n",
    "        #gene_end = df1[df1['gene']==gene_name]['gene_end'].values[0]\n",
    "\n",
    "        gene_start = db_mouse[gene_id].start\n",
    "\n",
    "        start = start_end_cds[i][0]-1-gene_start+5000\n",
    "        end = start_end_cds[i][1]-gene_start+5000\n",
    "        sequence = mouse_genes[tx_idx][start:end]\n",
    "\n",
    "        seq_list.append(sequence)\n",
    "\n",
    "    concatenated_seq = sum(seq_list, Seq(\"\"))\n",
    "\n",
    "    #take reverse complement to account for minus strand\n",
    "\n",
    "    strand = db_mouse[tx].strand\n",
    "    if strand=='-': #if minus strand\n",
    "        seq_true = concatenated_seq.reverse_complement()\n",
    "    elif strand=='+':\n",
    "        seq_true = concatenated_seq\n",
    "\n",
    "\n",
    "    mRNA = seq_true.transcribe()\n",
    "    prot_seq = mRNA.translate()\n",
    "\n",
    "    return mRNA, prot_seq"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 239,
   "metadata": {},
   "outputs": [],
   "source": [
    "#now doing an example of a gene on the minus strand\n",
    "unique_gene_list = list(unique_genes)\n",
    "#tx_ids = np.asarray(df1['transcript_id'])\n",
    "human_gene_name = 'KRAS'\n",
    "\n",
    "mRNA, protein = mouse_protein(human_gene_name, mouse_genes, db_mouse, unique_gene_list)"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "# Protein Sequence alignment\n",
    "- pairwise global alignment\n",
    "    - match score = 1\n",
    "    - gap penalty = 0"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 243,
   "metadata": {},
   "outputs": [],
   "source": [
    "from Bio import AlignIO\n",
    "import Bio.Align\n",
    "from Bio import pairwise2\n",
    "from Bio.pairwise2 import format_alignment"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 242,
   "metadata": {},
   "outputs": [],
   "source": [
    "#An example using P53\n",
    "#Generating mouse protein\n",
    "unique_gene_list = list(unique_genes)\n",
    "human_gene_name = 'TP53'\n",
    "\n",
    "mRNA, mouse_p53 = mouse_protein(human_gene_name, mouse_genes, db_mouse, unique_gene_list)\n",
    "\n",
    "#Generating human protein\n",
    "tx_ids = np.asarray(df1['transcript_id'])\n",
    "\n",
    "gene_name = 'TP53'\n",
    "\n",
    "SNP = impact_data.iloc[[idx]]['HGVSc'].values[0][-1] #this is just a filler; don't care about it; originally meant for KRAS\n",
    "#need to expand to other mutation types\n",
    "\n",
    "mRNA, human_p53, mRNA_mut, prot_seq_mut = human_protein(gene_name, unique_gene_list, tx_ids, SNP)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 247,
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "M---EEP-QSDP-SV-EP-PLSQETFSD-LWKLLPENNVLSP---LPSQA---MDDLMLS-PD-DI-EQW-FT-EDPGPD-EAP-RMPEAAPPVAP--APAA--P-T--PA---APAPA-PSWPLSSS-VPSQKTYQGS-YGFR-LGFLH-SGTAKSVT-CTYSPA-LNKM-FCQLAKTCPVQLWVDS-TPPP-GT-RVRAMAIYKQ-SQHMTEVVRRCPHHERCSDS-DGLAPPQHLIRVEGNLRV--EYLD-DRN-TFRHSVVVPYEPPEV-GSDC--TTIHYN-YMCNSSCMGGMNRRPILTIITLEDSSGNLLGRN-SFEVRVCACPGRDRRTEEENL-RKKGE---PHHELPPGST-KRALPNNTS--S-SPQP-KKKPLDGEYFTLQ-IRGRE-RFEMFRELNEALELKDAQ-AGK-EPG--G-SRAHSSH-LKS-KKGQSTSRHKKL-MF-KTE--GPDSD\n",
      "|   ||  |||  |  |  ||||||||  ||||||      |   |||     |||| |  |  |  |   |  |  ||  ||  |       |    ||||  | |  |    ||||| | ||| || |||||||||  |||  ||||  |||||||  |||||  |||  |||||||||||||| | | || |  |||||||||  |||||||||||||||||||  ||||||||||||||||    |||  ||  ||||||||||||||  ||    |||||  ||||||||||||||||||||||||||||||||  ||||||||||||||||||||  ||| |   |  ||||||  |||||  |   | || | ||||||||||||  ||||  |||||||||||||||||  |   |    | ||||||  ||  |||||||||||  |  |    |||||\n",
      "MTAMEE-SQSD-IS-LE-LPLSQETFS-GLWKLLP------PEDILPS--PHCMDDL-L-LP-QD-VE--EF-FE--GP-SEA-LR-------V--SGAPAAQDPVTETP-GPVAPAPATP-WPL-SSFVPSQKTYQG-NYGF-HLGFL-QSGTAKSV-MCTYSP-PLNK-LFCQLAKTCPVQLWV-SAT-PPAG-SRVRAMAIYK-KSQHMTEVVRRCPHHERCSD-GDGLAPPQHLIRVEGNL--YPEYL-EDR-QTFRHSVVVPYEPPE-AGS--EYTTIHY-KYMCNSSCMGGMNRRPILTIITLEDSSGNLLGR-DSFEVRVCACPGRDRRTEEEN-FRKK-EVLCP--ELPPGS-AKRALP--T-CTSASP-PQKKKPLDGEYFTL-KIRGR-KRFEMFRELNEALELKDA-HA--TE--ESGDSRAHSS-YLK-TKKGQSTSRHKK-TM-VK--KVGPDSD\n",
      "  Score=315\n",
      "\n"
     ]
    }
   ],
   "source": [
    "alignments = pairwise2.align.globalxx(human_p53, mouse_p53)\n",
    "print(format_alignment(*alignments[0]))"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 249,
   "metadata": {},
   "outputs": [],
   "source": [
    "#producing indeces of homologous sequences in each\n",
    "def align_idx(human_prot, mouse_prot):\n",
    "    \"Returns indexes of HOMOLOGOUS regions in mouse and human\"\n",
    "    \n",
    "    alignments = pairwise2.align.globalxx(human_prot, mouse_prot)\n",
    "\n",
    "    match_idx = match_index(*alignments[0])\n",
    "    \n",
    "    human_aln_seq = alignments[0][0] #human alignment sequence\n",
    "    mouse_aln_seq = alignments[0][1] #human alignment sequence\n",
    "\n",
    "    human_idx = []\n",
    "    mouse_idx = []\n",
    "    \n",
    "    for index in match_idx:\n",
    "        #calculate human original idx\n",
    "        gaps = human_aln_seq[:index].count('-')\n",
    "        original_index = len(human_aln_seq[:index]) - gaps\n",
    "        human_idx.append(original_index)\n",
    "        \n",
    "        #calculate mouse original idx\n",
    "        gaps = mouse_aln_seq[:index].count('-')\n",
    "        original_index = len(mouse_aln_seq[:index]) - gaps\n",
    "        mouse_idx.append(original_index)\n",
    "\n",
    "    return human_idx, mouse_idx\n",
    "    "
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "## Now performing this alignment for each of the orthologous proteins and saving to arrays\n",
    "\n",
    "- important note: ignore non-coding transcripts -- this is specific to MAP3K14 (of which only 2 muts are recorded)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 152,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/html": [
       "<div>\n",
       "<style scoped>\n",
       "    .dataframe tbody tr th:only-of-type {\n",
       "        vertical-align: middle;\n",
       "    }\n",
       "\n",
       "    .dataframe tbody tr th {\n",
       "        vertical-align: top;\n",
       "    }\n",
       "\n",
       "    .dataframe thead th {\n",
       "        text-align: right;\n",
       "    }\n",
       "</style>\n",
       "<table border=\"1\" class=\"dataframe\">\n",
       "  <thead>\n",
       "    <tr style=\"text-align: right;\">\n",
       "      <th></th>\n",
       "      <th>gene</th>\n",
       "      <th>human gene name</th>\n",
       "      <th>mouse gene name</th>\n",
       "      <th>mouse id</th>\n",
       "      <th>mouse id version</th>\n",
       "      <th>mouse transcript</th>\n",
       "    </tr>\n",
       "  </thead>\n",
       "  <tbody>\n",
       "    <tr>\n",
       "      <th>0</th>\n",
       "      <td>ABL1</td>\n",
       "      <td>ABL1</td>\n",
       "      <td>Abl1</td>\n",
       "      <td>ENSMUSG00000026842</td>\n",
       "      <td>ENSMUSG00000026842.16</td>\n",
       "      <td>ENSMUST00000028190.12</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>1</th>\n",
       "      <td>AC004906.3</td>\n",
       "      <td>NONE</td>\n",
       "      <td>NONE</td>\n",
       "      <td>NONE</td>\n",
       "      <td>NONE</td>\n",
       "      <td>NONE</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>2</th>\n",
       "      <td>AC008738.1</td>\n",
       "      <td>NONE</td>\n",
       "      <td>NONE</td>\n",
       "      <td>NONE</td>\n",
       "      <td>NONE</td>\n",
       "      <td>NONE</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>3</th>\n",
       "      <td>ACTG1</td>\n",
       "      <td>ACTG1</td>\n",
       "      <td>Actg1</td>\n",
       "      <td>ENSMUSG00000062825</td>\n",
       "      <td>ENSMUSG00000062825.15</td>\n",
       "      <td>ENSMUST00000071555.12</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>4</th>\n",
       "      <td>ACVR1</td>\n",
       "      <td>ACVR1</td>\n",
       "      <td>Acvr1</td>\n",
       "      <td>ENSMUSG00000026836</td>\n",
       "      <td>ENSMUSG00000026836.15</td>\n",
       "      <td>ENSMUST00000056376.11</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>...</th>\n",
       "      <td>...</td>\n",
       "      <td>...</td>\n",
       "      <td>...</td>\n",
       "      <td>...</td>\n",
       "      <td>...</td>\n",
       "      <td>...</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>589</th>\n",
       "      <td>XRCC2</td>\n",
       "      <td>XRCC2</td>\n",
       "      <td>Xrcc2</td>\n",
       "      <td>ENSMUSG00000028933</td>\n",
       "      <td>ENSMUSG00000028933.11</td>\n",
       "      <td>ENSMUST00000030773.11</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>590</th>\n",
       "      <td>YAP1</td>\n",
       "      <td>YAP1</td>\n",
       "      <td>Yap1</td>\n",
       "      <td>ENSMUSG00000053110</td>\n",
       "      <td>ENSMUSG00000053110.13</td>\n",
       "      <td>ENSMUST00000086580.11</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>591</th>\n",
       "      <td>YES1</td>\n",
       "      <td>YES1</td>\n",
       "      <td>Yes1</td>\n",
       "      <td>ENSMUSG00000014932</td>\n",
       "      <td>ENSMUSG00000014932.15</td>\n",
       "      <td>ENSMUST00000168707.5</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>592</th>\n",
       "      <td>ZFHX3</td>\n",
       "      <td>ZFHX3</td>\n",
       "      <td>Zfhx3</td>\n",
       "      <td>ENSMUSG00000038872</td>\n",
       "      <td>ENSMUSG00000038872.10</td>\n",
       "      <td>ENSMUST00000043896.9</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>593</th>\n",
       "      <td>ZRSR2</td>\n",
       "      <td>ZRSR2</td>\n",
       "      <td>Zrsr1</td>\n",
       "      <td>ENSMUSG00000044068</td>\n",
       "      <td>ENSMUSG00000044068.7</td>\n",
       "      <td>ENSMUST00000049506.7</td>\n",
       "    </tr>\n",
       "  </tbody>\n",
       "</table>\n",
       "<p>594 rows × 6 columns</p>\n",
       "</div>"
      ],
      "text/plain": [
       "           gene human gene name mouse gene name            mouse id  \\\n",
       "0          ABL1            ABL1            Abl1  ENSMUSG00000026842   \n",
       "1    AC004906.3            NONE            NONE                NONE   \n",
       "2    AC008738.1            NONE            NONE                NONE   \n",
       "3         ACTG1           ACTG1           Actg1  ENSMUSG00000062825   \n",
       "4         ACVR1           ACVR1           Acvr1  ENSMUSG00000026836   \n",
       "..          ...             ...             ...                 ...   \n",
       "589       XRCC2           XRCC2           Xrcc2  ENSMUSG00000028933   \n",
       "590        YAP1            YAP1            Yap1  ENSMUSG00000053110   \n",
       "591        YES1            YES1            Yes1  ENSMUSG00000014932   \n",
       "592       ZFHX3           ZFHX3           Zfhx3  ENSMUSG00000038872   \n",
       "593       ZRSR2           ZRSR2           Zrsr1  ENSMUSG00000044068   \n",
       "\n",
       "          mouse id version       mouse transcript  \n",
       "0    ENSMUSG00000026842.16  ENSMUST00000028190.12  \n",
       "1                     NONE                   NONE  \n",
       "2                     NONE                   NONE  \n",
       "3    ENSMUSG00000062825.15  ENSMUST00000071555.12  \n",
       "4    ENSMUSG00000026836.15  ENSMUST00000056376.11  \n",
       "..                     ...                    ...  \n",
       "589  ENSMUSG00000028933.11  ENSMUST00000030773.11  \n",
       "590  ENSMUSG00000053110.13  ENSMUST00000086580.11  \n",
       "591  ENSMUSG00000014932.15   ENSMUST00000168707.5  \n",
       "592  ENSMUSG00000038872.10   ENSMUST00000043896.9  \n",
       "593   ENSMUSG00000044068.7   ENSMUST00000049506.7  \n",
       "\n",
       "[594 rows x 6 columns]"
      ]
     },
     "execution_count": 152,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "homology_df"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 385,
   "metadata": {},
   "outputs": [
    {
     "name": "stderr",
     "output_type": "stream",
     "text": [
      "/Users/samgould/anaconda3/lib/python3.7/site-packages/Bio/Seq.py:2715: BiopythonWarning: Partial codon, len(sequence) not a multiple of three. Explicitly trim the sequence or add trailing N before translation. This may become an error in future.\n",
      "  BiopythonWarning)\n"
     ]
    }
   ],
   "source": [
    "#Generating human and mouse protein alignments and indeces\n",
    "unique_gene_list = list(unique_genes)\n",
    "tx_ids = np.asarray(df1['transcript_id'])\n",
    "SNP = impact_data.iloc[[idx]]['HGVSc'].values[0][-1] \n",
    "#this is just a filler; don't care about it; originally a mutation meant for KRAS\n",
    "\n",
    "human_alignments = []\n",
    "mouse_alignments = []\n",
    "\n",
    "#iterate through the genes\n",
    "for human_gene_name in unique_gene_list:\n",
    "    \n",
    "    tx_idx = unique_gene_list.index(human_gene_name)\n",
    "    tx = tx_ids[tx_idx]\n",
    "    cds = list(db.children(tx, order_by='+end', featuretype=['CDS'])) #only accessing cds    \n",
    "    \n",
    "    \n",
    "    #need to check if there exists an orthologue in mouse\n",
    "    #if not, skip the alignment process\n",
    "    if homology_df[homology_df['gene']==human_gene_name]['mouse transcript'].values[0] == 'NONE':\n",
    "        human_alignments.append(['no_ortholog'])\n",
    "        mouse_alignments.append(['no_ortholog'])\n",
    "    \n",
    "    elif len(cds)==0: #ignore non-coding transcripts -- this is specific to MAP3K14 (of which only 2 muts are recorded)\n",
    "        \n",
    "        human_alignments.append(['non_coding'])\n",
    "        mouse_alignments.append(['non_coding'])\n",
    "        \n",
    "    else:\n",
    "\n",
    "        gene_name = human_gene_name\n",
    "\n",
    "        mRNA, mouse_prot = mouse_protein(gene_name, mouse_genes, db_mouse, unique_gene_list)\n",
    "\n",
    "        mRNA, human_prot, mRNA_mut, prot_seq_mut = human_protein(gene_name, unique_gene_list, tx_ids, SNP)\n",
    "\n",
    "        human_idx, mouse_idx = align_idx(human_prot, mouse_prot)\n",
    "        \n",
    "        human_alignments.append(human_idx)\n",
    "        mouse_alignments.append(mouse_idx)\n",
    "        "
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 386,
   "metadata": {},
   "outputs": [],
   "source": [
    "#and now saving these results\n",
    "\n",
    "human_align_array = np.asarray(human_alignments, dtype=object)\n",
    "mouse_align_array = np.asarray(mouse_alignments, dtype=object)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 387,
   "metadata": {},
   "outputs": [],
   "source": [
    "path = '/Volumes/Sam_G_SSD/human_mouse_alignments/'\n",
    "#np.save(path+'human_alignment_idx.npy', human_align_array)\n",
    "#np.save(path+'mouse_alignment_idx.npy', mouse_align_array)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 270,
   "metadata": {},
   "outputs": [],
   "source": [
    "#For loading these alignment files back in\n",
    "path = '/Volumes/Sam_G_SSD/human_mouse_alignments/'\n",
    "human_prot_align = np.load(path+'human_alignment_idx.npy', allow_pickle=True)\n",
    "mouse_prot_align = np.load(path+'mouse_alignment_idx.npy', allow_pickle=True)\n",
    "\n"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "## Generating list of DNA sequence positions of each codon in given coding sequence\n",
    "- This allows mapping of the mutations onto protein sequence\n",
    "- Need to do this for both mouse AND human sequences\n",
    "\n",
    "- Dealing with the plus and minus strands could be a bit annoying here. In general the mutations in the IMPACT dataset are reported as the plus strand, so I will follow this convention. But, this will need to be double checked for sure."
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 369,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "array(['+'], dtype=object)"
      ]
     },
     "execution_count": 369,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "impact_data['Strand'].unique()\n",
    "#all of the mutations are recorded with respect to the + strand in the IMPACT dataset"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 298,
   "metadata": {},
   "outputs": [],
   "source": [
    "#now doing an example of a gene on the minus strand\n",
    "\n",
    "def human_protein_2(gene_name, unique_gene_list, tx_ids, SNP):\n",
    "    tx_idx = unique_gene_list.index(gene_name)\n",
    "    tx = tx_ids[tx_idx]\n",
    "\n",
    "    #always order by + strand and then deal with - end genes later on\n",
    "    cds = list(db.children(tx, order_by='+end', featuretype=['CDS'])) #only accessing cds\n",
    "    #CDS refers to all of the exons in the gene\n",
    "\n",
    "    #DEFINING the start and end of each coding exon\n",
    "    start_end_cds = [[i.start, i.end] for i in cds]\n",
    "\n",
    "\n",
    "    #23 = X\n",
    "    seq_list = []\n",
    "    for i in range(len(start_end_cds)):\n",
    "        #need to put it in the correct indexing frame for the loaded in genes\n",
    "        gene_start = df1[df1['gene']==gene_name]['gene_start'].values[0]\n",
    "        #gene_end = df1[df1['gene']==gene_name]['gene_end'].values[0]\n",
    "\n",
    "        start = start_end_cds[i][0]-1-gene_start+5000\n",
    "        end = start_end_cds[i][1]-gene_start+5000\n",
    "        sequence = impact_genes[tx_idx][start:end]\n",
    "\n",
    "        seq_list.append(sequence)\n",
    "\n",
    "    concatenated_seq = sum(seq_list, Seq(\"\"))\n",
    "\n",
    "    #take reverse complement to account for minus strand\n",
    "    strand = df1[df1['gene']==gene_name]['strand'].values[0]\n",
    "    if strand=='-': #if minus strand\n",
    "        seq_true = concatenated_seq.reverse_complement()\n",
    "    elif strand=='+':\n",
    "        seq_true = concatenated_seq\n",
    "\n",
    "\n",
    "    mRNA = seq_true.transcribe()\n",
    "    prot_seq = mRNA.translate()\n",
    "\n",
    "    #-_______________________________MUTATIONS_____________________________#\n",
    "    #information about mutation of interest\n",
    "    #FOR NOW ONLY LOOKING AT SNPs\n",
    "    snp = SNP\n",
    "\n",
    "    coding_location1 = impact_data.iloc[[idx]]['HGVSc'].values[0].split('.')[2]\n",
    "    coding_location = int(re.findall(r'\\d+', coding_location1)[0])\n",
    "\n",
    "    seq_mut = seq_true[0:coding_location-1] + snp + seq_true[coding_location:]\n",
    "    mRNA_mut = seq_mut.transcribe()\n",
    "    prot_seq_mut = mRNA_mut.translate()\n",
    "\n",
    "    \n",
    "    return mRNA, prot_seq, mRNA_mut, prot_seq_mut, start_end_cds, concatenated_seq"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 299,
   "metadata": {},
   "outputs": [],
   "source": [
    "def mouse_protein_2(human_gene_name, mouse_genes, db_mouse, unique_gene_list):\n",
    "    \n",
    "    tx_idx = unique_gene_list.index(human_gene_name)\n",
    "    \n",
    "    gene_id = homology_df[homology_df['gene']==human_gene_name]['mouse id version'].values[0]\n",
    "    tx = homology_df[homology_df['gene']==human_gene_name]['mouse transcript'].values[0]\n",
    "\n",
    "\n",
    "    #always order by + strand and then deal with - end genes later on\n",
    "    cds = list(db_mouse.children(tx, order_by='+end', featuretype=['CDS'])) #only accessing cds\n",
    "    #CDS refers to all of the exons in the gene\n",
    "\n",
    "    #DEFINING the start and end of each coding exon\n",
    "    start_end_cds = [[i.start, i.end] for i in cds]\n",
    "\n",
    "    seq_list = []\n",
    "    for i in range(len(start_end_cds)):\n",
    "        #need to put it in the correct indexing frame for the loaded in genes\n",
    "        #gene_start = df1[df1['gene']==gene_name]['gene_start'].values[0]\n",
    "        #gene_end = df1[df1['gene']==gene_name]['gene_end'].values[0]\n",
    "\n",
    "        gene_start = db_mouse[gene_id].start\n",
    "\n",
    "        start = start_end_cds[i][0]-1-gene_start+5000\n",
    "        end = start_end_cds[i][1]-gene_start+5000\n",
    "        sequence = mouse_genes[tx_idx][start:end]\n",
    "\n",
    "        seq_list.append(sequence)\n",
    "\n",
    "    concatenated_seq = sum(seq_list, Seq(\"\"))\n",
    "\n",
    "    #take reverse complement to account for minus strand\n",
    "\n",
    "    strand = db_mouse[tx].strand\n",
    "    if strand=='-': #if minus strand\n",
    "        seq_true = concatenated_seq.reverse_complement()\n",
    "    elif strand=='+':\n",
    "        seq_true = concatenated_seq\n",
    "\n",
    "\n",
    "    mRNA = seq_true.transcribe()\n",
    "    prot_seq = mRNA.translate()\n",
    "\n",
    "    return mRNA, prot_seq, start_end_cds, concatenated_seq"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 300,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/html": [
       "<div>\n",
       "<style scoped>\n",
       "    .dataframe tbody tr th:only-of-type {\n",
       "        vertical-align: middle;\n",
       "    }\n",
       "\n",
       "    .dataframe tbody tr th {\n",
       "        vertical-align: top;\n",
       "    }\n",
       "\n",
       "    .dataframe thead th {\n",
       "        text-align: right;\n",
       "    }\n",
       "</style>\n",
       "<table border=\"1\" class=\"dataframe\">\n",
       "  <thead>\n",
       "    <tr style=\"text-align: right;\">\n",
       "      <th></th>\n",
       "      <th>gene</th>\n",
       "      <th>gene_id</th>\n",
       "      <th>transcript_id</th>\n",
       "      <th>chrom</th>\n",
       "      <th>gene_start</th>\n",
       "      <th>gene_end</th>\n",
       "      <th>transcript_start</th>\n",
       "      <th>transcript_end</th>\n",
       "      <th>strand</th>\n",
       "    </tr>\n",
       "  </thead>\n",
       "  <tbody>\n",
       "    <tr>\n",
       "      <th>0</th>\n",
       "      <td>ABL1</td>\n",
       "      <td>ENSG00000097007.13</td>\n",
       "      <td>ENST00000318560.5</td>\n",
       "      <td>chr9</td>\n",
       "      <td>133589333</td>\n",
       "      <td>133763062</td>\n",
       "      <td>133710453</td>\n",
       "      <td>133763062</td>\n",
       "      <td>+</td>\n",
       "    </tr>\n",
       "  </tbody>\n",
       "</table>\n",
       "</div>"
      ],
      "text/plain": [
       "   gene             gene_id      transcript_id chrom  gene_start   gene_end  \\\n",
       "0  ABL1  ENSG00000097007.13  ENST00000318560.5  chr9   133589333  133763062   \n",
       "\n",
       "   transcript_start  transcript_end strand  \n",
       "0         133710453       133763062      +  "
      ]
     },
     "execution_count": 300,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "df1[df1['gene']=='ABL1']"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 413,
   "metadata": {},
   "outputs": [],
   "source": [
    "unique_gene_list = list(unique_genes)\n",
    "tx_ids = np.asarray(df1['transcript_id'])\n",
    "SNP = impact_data.iloc[[idx]]['HGVSc'].values[0][-1] \n",
    "\n",
    "gene_name = 'TP53'\n",
    "\n",
    "mRNA, mouse_prot, start_end_cds_m, concatenated_seq_m = mouse_protein_2(gene_name, mouse_genes, db_mouse, unique_gene_list)\n",
    "\n",
    "mRNA, human_prot, mRNA_mut, prot_seq_mut, start_end_cds_h, concatenated_seq_h = human_protein_2(gene_name, unique_gene_list, tx_ids, SNP)\n",
    "\n",
    "\n"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 414,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "'+'"
      ]
     },
     "execution_count": 414,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "gene_name = 'TP53'\n",
    "gene_id = homology_df[homology_df['gene']==gene_name]['mouse id version'].values[0]\n",
    "strand = db_mouse[gene_id].strand\n",
    "strand"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 430,
   "metadata": {},
   "outputs": [],
   "source": [
    "def mouse_codons(gene_name, start_end_cds_m, concatenated_seq_m):\n",
    "    #and now doing the same, but accounting for plus or minus strand\n",
    "    gene_id = homology_df[homology_df['gene']==gene_name]['mouse id version'].values[0]\n",
    "    strand = db_mouse[gene_id].strand\n",
    "\n",
    "    if strand=='+':\n",
    "        #generating list with fleshed out indeces\n",
    "        full_list = []\n",
    "        for i in start_end_cds_m:\n",
    "            k = list(range(i[0], i[1]+1))\n",
    "            for num in k:\n",
    "                full_list.append(num)\n",
    "\n",
    "        #and splitting it up by 3s to create codons\n",
    "        codons = []\n",
    "        for i in range(0, len(full_list), 3):\n",
    "            codons.append(full_list[i:i+3])\n",
    "\n",
    "\n",
    "        #now checking and generating corresponding sequence\n",
    "        a_a_list = []\n",
    "        dna_seq_list = []\n",
    "        for codon_num in range(len(codons)):\n",
    "\n",
    "            tx_idx = unique_gene_list.index(gene_name)\n",
    "            gene_id = homology_df[homology_df['gene']==gene_name]['mouse id version'].values[0]\n",
    "\n",
    "            gene_start = db_mouse[gene_id].start\n",
    "\n",
    "            c1 = codons[codon_num][0]-1-gene_start+5000\n",
    "            c2 = codons[codon_num][1]-1-gene_start+5000\n",
    "            c3 = codons[codon_num][2]-1-gene_start+5000\n",
    "\n",
    "            seq_list = []\n",
    "            seq_list.append(mouse_genes[tx_idx][c1])\n",
    "            seq_list.append(mouse_genes[tx_idx][c2])\n",
    "            seq_list.append(mouse_genes[tx_idx][c3])\n",
    "            concatenated_seq = sum(seq_list, Seq(\"\"))\n",
    "            mrna = concatenated_seq.transcribe()\n",
    "            aa = mrna.translate()\n",
    "\n",
    "\n",
    "            a_a_list.append(aa)\n",
    "            dna_seq_list.append(concatenated_seq) #contains dna sequence corresponding\n",
    "\n",
    "    elif strand=='-':\n",
    "        #generating list with fleshed out indeces\n",
    "        full_list = []\n",
    "        for i in start_end_cds_m:\n",
    "            k = list(range(i[0], i[1]+1))\n",
    "            for num in k:\n",
    "                full_list.append(num)\n",
    "\n",
    "\n",
    "        #reversing to account for - strand\n",
    "        full_list = full_list[::-1]\n",
    "\n",
    "        #and splitting it up by 3s to create codons\n",
    "        codons = []\n",
    "        for i in range(0, len(full_list), 3):\n",
    "            codons.append(full_list[i:i+3])\n",
    "\n",
    "\n",
    "        #now checking and generating corresponding sequence\n",
    "        a_a_list = []\n",
    "        dna_seq_list = []\n",
    "        for codon_num in range(len(codons)):\n",
    "\n",
    "            tx_idx = unique_gene_list.index(gene_name)\n",
    "            gene_id = homology_df[homology_df['gene']==gene_name]['mouse id version'].values[0]\n",
    "\n",
    "            gene_start = db_mouse[gene_id].start\n",
    "\n",
    "            c1 = codons[codon_num][0]-1-gene_start+5000\n",
    "            c2 = codons[codon_num][1]-1-gene_start+5000\n",
    "            c3 = codons[codon_num][2]-1-gene_start+5000\n",
    "\n",
    "            seq_list = []\n",
    "            seq_list.append(mouse_genes[tx_idx][c1])\n",
    "            seq_list.append(mouse_genes[tx_idx][c2])\n",
    "            seq_list.append(mouse_genes[tx_idx][c3])\n",
    "            concatenated_seq = sum(seq_list, Seq(\"\"))\n",
    "            mrna = concatenated_seq.complement().transcribe()\n",
    "            aa = mrna.translate()\n",
    "\n",
    "            a_a_list.append(aa)\n",
    "            dna_seq_list.append(concatenated_seq) #contains dna sequence corresponding\n",
    "\n",
    "    return codons, dna_seq_list, a_a_list"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 436,
   "metadata": {},
   "outputs": [],
   "source": [
    "unique_gene_list = list(unique_genes)\n",
    "tx_ids = np.asarray(df1['transcript_id'])\n",
    "SNP = impact_data.iloc[[idx]]['HGVSc'].values[0][-1] \n",
    "\n",
    "gene_name = 'ABL1'\n",
    "\n",
    "mRNA, mouse_prot, start_end_cds_m, concatenated_seq_m = mouse_protein_2(gene_name, mouse_genes, db_mouse, unique_gene_list)\n",
    "\n",
    "codons, dna_seq_list, a_a_list = mouse_codons(gene_name, start_end_cds_m, concatenated_seq_m)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 437,
   "metadata": {},
   "outputs": [],
   "source": [
    "for i in range(len(mouse_prot)):\n",
    "    if mouse_prot[i] == a_a_list[i][0]:\n",
    "        continue\n",
    "    else:\n",
    "        print(i)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 439,
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "+\n",
      "P\n",
      "P\n",
      "CCC\n"
     ]
    }
   ],
   "source": [
    "gene_id = homology_df[homology_df['gene']==gene_name]['mouse id version'].values[0]\n",
    "strand = db_mouse[gene_id].strand\n",
    "\n",
    "print(strand)\n",
    "print(mouse_prot[57])\n",
    "print(a_a_list[57][0])\n",
    "print(dna_seq_list[57])"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 443,
   "metadata": {},
   "outputs": [],
   "source": [
    "def human_codons(gene_name, start_end_cds_h, concatenated_seq_h): \n",
    "    #other variables defined within that are not inputs, but simply defined in previous cells\n",
    "    \n",
    "    tx_idx = unique_gene_list.index(gene_name)\n",
    "    tx = tx_ids[tx_idx]\n",
    "    \n",
    "    strand = df1[df1['gene']==gene_name]['strand'].values[0]\n",
    "\n",
    "    \n",
    "    if strand=='+':\n",
    "        #generating list with fleshed out indeces\n",
    "        full_list = []\n",
    "        for i in start_end_cds_h:\n",
    "            k = list(range(i[0], i[1]+1))\n",
    "            for num in k:\n",
    "                full_list.append(num)\n",
    "\n",
    "        #and splitting it up by 3s to create codons\n",
    "        codons = []\n",
    "        for i in range(0, len(full_list), 3):\n",
    "            codons.append(full_list[i:i+3])\n",
    "\n",
    "\n",
    "        #now checking and generating corresponding sequence\n",
    "        a_a_list = []\n",
    "        dna_seq_list = []\n",
    "        for codon_num in range(len(codons)):\n",
    "\n",
    "            gene_start = df1[df1['gene']==gene_name]['gene_start'].values[0]\n",
    "\n",
    "            c1 = codons[codon_num][0]-1-gene_start+5000\n",
    "            c2 = codons[codon_num][1]-1-gene_start+5000\n",
    "            c3 = codons[codon_num][2]-1-gene_start+5000\n",
    "\n",
    "            seq_list = []\n",
    "            seq_list.append(impact_genes[tx_idx][c1])\n",
    "            seq_list.append(impact_genes[tx_idx][c2])\n",
    "            seq_list.append(impact_genes[tx_idx][c3])\n",
    "            concatenated_seq = sum(seq_list, Seq(\"\"))\n",
    "            mrna = concatenated_seq.transcribe()\n",
    "            aa = mrna.translate()\n",
    "\n",
    "\n",
    "            a_a_list.append(aa)\n",
    "            dna_seq_list.append(concatenated_seq) #contains dna sequence corresponding\n",
    "\n",
    "    elif strand=='-':\n",
    "        #generating list with fleshed out indeces\n",
    "        full_list = []\n",
    "        for i in start_end_cds_h:\n",
    "            k = list(range(i[0], i[1]+1))\n",
    "            for num in k:\n",
    "                full_list.append(num)\n",
    "\n",
    "\n",
    "        #reversing to account for - strand\n",
    "        full_list = full_list[::-1]\n",
    "\n",
    "        #and splitting it up by 3s to create codons\n",
    "        codons = []\n",
    "        for i in range(0, len(full_list), 3):\n",
    "            codons.append(full_list[i:i+3])\n",
    "\n",
    "\n",
    "        #now checking and generating corresponding sequence\n",
    "        a_a_list = []\n",
    "        dna_seq_list = []\n",
    "        for codon_num in range(len(codons)):\n",
    "\n",
    "            gene_start = df1[df1['gene']==gene_name]['gene_start'].values[0]\n",
    "\n",
    "            c1 = codons[codon_num][0]-1-gene_start+5000\n",
    "            c2 = codons[codon_num][1]-1-gene_start+5000\n",
    "            c3 = codons[codon_num][2]-1-gene_start+5000\n",
    "\n",
    "            seq_list = []\n",
    "            seq_list.append(impact_genes[tx_idx][c1])\n",
    "            seq_list.append(impact_genes[tx_idx][c2])\n",
    "            seq_list.append(impact_genes[tx_idx][c3])\n",
    "            concatenated_seq = sum(seq_list, Seq(\"\"))\n",
    "            \n",
    "            mrna = concatenated_seq.complement().transcribe()\n",
    "            aa = mrna.translate()\n",
    "\n",
    "            a_a_list.append(aa)\n",
    "            dna_seq_list.append(concatenated_seq) #contains dna sequence corresponding\n",
    "\n",
    "    return codons, dna_seq_list, a_a_list\n"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 480,
   "metadata": {},
   "outputs": [],
   "source": [
    "unique_gene_list = list(unique_genes)\n",
    "tx_ids = np.asarray(df1['transcript_id'])\n",
    "SNP = impact_data.iloc[[idx]]['HGVSc'].values[0][-1] \n",
    "\n",
    "gene_name = 'ABL1'\n",
    "\n",
    "#mRNA, mouse_prot, start_end_cds_m, concatenated_seq_m = mouse_protein_2(gene_name, mouse_genes, db_mouse, unique_gene_list)\n",
    "\n",
    "mRNA, human_prot, mRNA_mut, prot_seq_mut, start_end_cds_h, concatenated_seq_h = human_protein_2(gene_name, unique_gene_list, tx_ids, SNP)\n",
    "\n",
    "\n",
    "codons, dna_seq_list, a_a_list = human_codons(gene_name, start_end_cds_h, concatenated_seq_h)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 481,
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "MLEICLKLVGCKSKKGLSSSSSCYLEEALQRPVASDFEPQGLSEAARWNSKENLLAGPSENDPNLFVALYDFVASGDNTLSITKGEKLRVLGYNHNGEWCEAQTKNGQGWVPSNYITPVNSLEKHSWYHGPVSRNAAEYLLSSGINGSFLVRESESSPGQRSISLRYEGRVYHYRINTASDGKLYVSSESRFNTLAELVHHHSTVADGLITTLHYPAPKRNKPTVYGVSPNYDKWEMERTDITMKHKLGGGQYGEVYEGVWKKYSLTVAVKTLKEDTMEVEEFLKEAAVMKEIKHPNLVQLLGVCTREPPFYIITEFMTYGNLLDYLRECNRQEVNAVVLLYMATQISSAMEYLEKKNFIHRDLAARNCLVGENHLVKVADFGLSRLMTGDTYTAHAGAKFPIKWTAPESLAYNKFSIKSDVWAFGVLLWEIATYGMSPYPGIDLSQVYELLEKDYRMERPEGCPEKVYELMRACWQWNPSDRPSFAEIHQAFETMFQESSISDEVEKELGKQGVRGAVSTLLQAPELPTKTRTSRRAAEHRDTTDVPEMPHSKGQGESDPLDHEPAVSPLLPRKERGPPEGGLNEDERLLPKDKKTNLFSALIKKKKKTAPTPPKRSSSFREMDGQPERRGAGEEEGRDISNGALAFTPLDTADPAKSPKPSNGAGVPNGALRESGGSGFRSPHLWKKSSTLTSSRLATGEEEGGGSSSKRFLRSCSASCVPHGAKDTEWRSVTLPRDLQSTGRQFDSSTFGGHKSEKPALPRKRAGENRSDQVTRGTVTPPPRLVKKNEEAADEVFKDIMESSPGSSPPNLTPKPLRRQVTVAPASGLPHKEEAGKGSALGTPAAAEPVTPTSKAGSGAPGGTSKGPAEESRVRRHKHSSESPGRDKGKLSRLKPAPPPPPAASAGKAGGKPSQSPSQEAAGEAVLGAKTKATSLVDAVNSDAAKPSQPGEGLKKPVLPATPKPQSAKPSGTPISPAPVPSTLPSASSALAGDQPSSTAFIPLISTRVSLRKTRQPPERIASGAITKGVVLDSTEALCLAISRNSEQMASHSAVLEAGKNLYTFCVSYVDSIQQMRNKFAFREAINKLENNLRELQICPATAGSGPAATQDFSKLLSSVKEISDIVQR\n"
     ]
    }
   ],
   "source": [
    "print(human_prot)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 450,
   "metadata": {},
   "outputs": [],
   "source": [
    "for i in range(len(human_prot)):\n",
    "    if human_prot[i] == a_a_list[i][0]:\n",
    "        continue\n",
    "    else:\n",
    "        print(i)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 451,
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "-\n",
      "P\n",
      "P\n",
      "GGT\n"
     ]
    }
   ],
   "source": [
    "\n",
    "strand = df1[df1['gene']==gene_name]['strand'].values[0]\n",
    "\n",
    "print(strand)\n",
    "print(human_prot[57])\n",
    "print(a_a_list[57][0])\n",
    "print(dna_seq_list[57])"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "## Now iterating through and generating this DNA sequence-codon match for each gene\n",
    "\n",
    "- excluding same genes as before\n",
    "- Again, important to be mindful of strand. Everything I've written here looks at + strand for sequence\n",
    "- Had to exclude RYBP because of weird error with annotation file\n",
    "    - This means that the alignment with mouse generated above is also fucked up\n",
    "    - I can go back and fix this manually...\n",
    "    - I should get a list and count of all of the excluded genes..."
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 467,
   "metadata": {},
   "outputs": [],
   "source": [
    "#Generating human and mouse protein alignments and indeces\n",
    "\n",
    "tx_ids = np.asarray(df1['transcript_id'])\n",
    "SNP = impact_data.iloc[[idx]]['HGVSc'].values[0][-1] \n",
    "#this is just a filler; don't care about it; originally a mutation meant for KRAS\n",
    "\n",
    "human_codon_locations = []\n",
    "human_codon_seqs = []\n",
    "human_aa = []\n",
    "\n",
    "mouse_codon_locations = []\n",
    "mouse_codon_seqs = []\n",
    "mouse_aa = []\n",
    "\n",
    "\n",
    "#iterate through the genes\n",
    "for human_gene_name in unique_gene_list:\n",
    "    \n",
    "    tx_idx = unique_gene_list.index(human_gene_name)\n",
    "    tx = tx_ids[tx_idx]\n",
    "    cds = list(db.children(tx, order_by='+end', featuretype=['CDS'])) #only accessing cds    \n",
    "    \n",
    "    \n",
    "    #need to check if there exists an orthologue in mouse\n",
    "    #if not, skip the alignment process\n",
    "    if homology_df[homology_df['gene']==human_gene_name]['mouse transcript'].values[0] == 'NONE':\n",
    "        \n",
    "        human_codon_locations.append(['no_ortholog'])\n",
    "        human_codon_seqs.append(['no_ortholog'])\n",
    "        human_aa.append(['no_ortholog'])\n",
    "\n",
    "        mouse_codon_locations.append(['no_ortholog'])\n",
    "        mouse_codon_seqs.append(['no_ortholog'])\n",
    "        mouse_aa.append(['no_ortholog'])\n",
    "        \n",
    "        \n",
    "    elif len(cds)==0: #ignore non-coding transcripts -- this is specific to MAP3K14 (of which only 2 muts are recorded)\n",
    "        \n",
    "        human_codon_locations.append(['non_coding'])\n",
    "        human_codon_seqs.append(['non_coding'])\n",
    "        human_aa.append(['non_coding'])\n",
    "\n",
    "        mouse_codon_locations.append(['non_coding'])\n",
    "        mouse_codon_seqs.append(['non_coding'])\n",
    "        mouse_aa.append(['non_coding'])\n",
    "        \n",
    "        \n",
    "    elif human_gene_name == unique_gene_list[480]: #avoiding weird RYBP error\n",
    "\n",
    "        human_codon_locations.append(['annotation_error'])\n",
    "        human_codon_seqs.append(['annotation_error'])\n",
    "        human_aa.append(['annotation_error'])\n",
    "\n",
    "        mouse_codon_locations.append(['annotation_error'])\n",
    "        mouse_codon_seqs.append(['annotation_error'])\n",
    "        mouse_aa.append(['annotation_error'])\n",
    "\n",
    "    else:\n",
    "\n",
    "        gene_name = human_gene_name\n",
    "\n",
    "        #first human\n",
    "        mRNA, human_prot, mRNA_mut, prot_seq_mut, start_end_cds_h, concatenated_seq_h = human_protein_2(gene_name, unique_gene_list, tx_ids, SNP)\n",
    "        codons, dna_seq_list, a_a_list = human_codons(gene_name, start_end_cds_h, concatenated_seq_h)\n",
    "        \n",
    "        human_codon_locations.append(codons)\n",
    "        human_codon_seqs.append(dna_seq_list)\n",
    "        human_aa.append(a_a_list)\n",
    "        \n",
    "        #and then mouse\n",
    "        \n",
    "        mRNA, mouse_prot, start_end_cds_m, concatenated_seq_m = mouse_protein_2(gene_name, mouse_genes, db_mouse, unique_gene_list)\n",
    "        codons, dna_seq_list, a_a_list = mouse_codons(gene_name, start_end_cds_m, concatenated_seq_m)\n",
    "        \n",
    "        mouse_codon_locations.append(codons)\n",
    "        mouse_codon_seqs.append(dna_seq_list)\n",
    "        mouse_aa.append(a_a_list)\n",
    "        \n",
    "        "
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 468,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "594"
      ]
     },
     "execution_count": 468,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "len(mouse_aa)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 471,
   "metadata": {},
   "outputs": [],
   "source": [
    "#and saving the resulting arrays etc.\n",
    "path = '/Volumes/Sam_G_SSD/human_mouse_alignments/'\n",
    "\n",
    "#human_codon_locations_arr = np.asarray(human_codon_locations, dtype=object)\n",
    "#human_codon_seqs_arr = np.asarray(human_codon_seqs, dtype=object)\n",
    "#human_aa_arr = np.asarray(human_aa, dtype=object)\n",
    "\n",
    "#mouse_codon_locations_arr = np.asarray(mouse_codon_locations, dtype=object)\n",
    "#mouse_codon_seqs_arr = np.asarray(mouse_codon_seqs, dtype=object)\n",
    "#mouse_aa_arr = np.asarray(mouse_aa, dtype=object)\n",
    "\n",
    "#np.save(path+'human_codon_locations.npy', human_codon_locations_arr)\n",
    "#np.save(path+'human_codon_seqs.npy', human_codon_seqs_arr)\n",
    "#np.save(path+'human_aa.npy', human_aa_arr)\n",
    "\n",
    "#np.save(path+'mouse_codon_locations.npy', mouse_codon_locations_arr)\n",
    "#np.save(path+'mouse_codon_seqs.npy', mouse_codon_seqs_arr)\n",
    "#np.save(path+'mouse_aa.npy', mouse_aa_arr)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 10,
   "metadata": {},
   "outputs": [],
   "source": [
    "#and for loading in this information\n",
    "path = '/Volumes/Sam_G_SSD/human_mouse_alignments/'\n",
    "\n",
    "human_codon_locations = np.load(path+'human_codon_locations.npy', allow_pickle=True)\n",
    "human_codon_seqs = np.load(path+'human_codon_seqs.npy', allow_pickle=True)\n",
    "human_aa = np.load(path+'human_aa.npy', allow_pickle=True)\n",
    "\n",
    "mouse_codon_locations = np.load(path+'mouse_codon_locations.npy', allow_pickle=True)\n",
    "mouse_codon_seqs = np.load(path+'mouse_codon_seqs.npy', allow_pickle=True)\n",
    "mouse_aa = np.load(path+'mouse_aa.npy', allow_pickle=True)"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "## Enumerating all of the genes that are excluded from analysis"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 17,
   "metadata": {},
   "outputs": [],
   "source": [
    "excluded_genes = []\n",
    "for i in range(len(mouse_aa)):\n",
    "    \n",
    "    if len(mouse_aa[i])==1:\n",
    "        excluded_genes.append(unique_genes[i])"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 20,
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "There are 56 excluded genes.\n"
     ]
    }
   ],
   "source": [
    "print('There are ' + str(len(excluded_genes)) + ' excluded genes.')"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 29,
   "metadata": {},
   "outputs": [],
   "source": [
    "num_mutations_excluded = 0\n",
    "num_excluded = []\n",
    "for i in excluded_genes:\n",
    "    num_exc = len(impact_data[impact_data['Hugo_Symbol']==i])\n",
    "    num_mutations_excluded += num_exc\n",
    "    num_excluded.append(num_exc)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 30,
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "There are 7762 mutations excluded.\n",
      "This represents 1.84% of all mutations in the dataset.\n"
     ]
    }
   ],
   "source": [
    "print('There are ' + str(num_mutations_excluded) + ' mutations excluded.')\n",
    "\n",
    "percent = num_mutations_excluded/len(impact_data)\n",
    "print('This represents ' + str(np.round(percent*100, 2)) + '% of all mutations in the dataset.')\n"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 33,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/html": [
       "<div>\n",
       "<style scoped>\n",
       "    .dataframe tbody tr th:only-of-type {\n",
       "        vertical-align: middle;\n",
       "    }\n",
       "\n",
       "    .dataframe tbody tr th {\n",
       "        vertical-align: top;\n",
       "    }\n",
       "\n",
       "    .dataframe thead th {\n",
       "        text-align: right;\n",
       "    }\n",
       "</style>\n",
       "<table border=\"1\" class=\"dataframe\">\n",
       "  <thead>\n",
       "    <tr style=\"text-align: right;\">\n",
       "      <th></th>\n",
       "      <th>gene</th>\n",
       "      <th>num mutations</th>\n",
       "    </tr>\n",
       "  </thead>\n",
       "  <tbody>\n",
       "    <tr>\n",
       "      <th>0</th>\n",
       "      <td>AC004906.3</td>\n",
       "      <td>1</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>1</th>\n",
       "      <td>AC008738.1</td>\n",
       "      <td>6</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>2</th>\n",
       "      <td>AP003419.16</td>\n",
       "      <td>1</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>3</th>\n",
       "      <td>C1orf147</td>\n",
       "      <td>4</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>4</th>\n",
       "      <td>CD58</td>\n",
       "      <td>80</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>5</th>\n",
       "      <td>CTD-2278I10.6</td>\n",
       "      <td>1</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>6</th>\n",
       "      <td>CTD-2330K9.2</td>\n",
       "      <td>1</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>7</th>\n",
       "      <td>CTD-2540B15.7</td>\n",
       "      <td>1</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>8</th>\n",
       "      <td>CTD-2561B21.3</td>\n",
       "      <td>1</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>9</th>\n",
       "      <td>FAM175A</td>\n",
       "      <td>192</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>10</th>\n",
       "      <td>FAM46C</td>\n",
       "      <td>298</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>11</th>\n",
       "      <td>FAM58A</td>\n",
       "      <td>179</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>12</th>\n",
       "      <td>GTF2I</td>\n",
       "      <td>3</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>13</th>\n",
       "      <td>H3F3A</td>\n",
       "      <td>135</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>14</th>\n",
       "      <td>H3F3B</td>\n",
       "      <td>113</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>15</th>\n",
       "      <td>H3F3C</td>\n",
       "      <td>224</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>16</th>\n",
       "      <td>HIST1H1B</td>\n",
       "      <td>62</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>17</th>\n",
       "      <td>HIST1H1C</td>\n",
       "      <td>487</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>18</th>\n",
       "      <td>HIST1H1D</td>\n",
       "      <td>70</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>19</th>\n",
       "      <td>HIST1H1E</td>\n",
       "      <td>227</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>20</th>\n",
       "      <td>HIST1H2AC</td>\n",
       "      <td>35</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>21</th>\n",
       "      <td>HIST1H2AG</td>\n",
       "      <td>29</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>22</th>\n",
       "      <td>HIST1H2AL</td>\n",
       "      <td>9</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>23</th>\n",
       "      <td>HIST1H2AM</td>\n",
       "      <td>44</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>24</th>\n",
       "      <td>HIST1H2BC</td>\n",
       "      <td>31</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>25</th>\n",
       "      <td>HIST1H2BD</td>\n",
       "      <td>183</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>26</th>\n",
       "      <td>HIST1H2BG</td>\n",
       "      <td>22</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>27</th>\n",
       "      <td>HIST1H2BJ</td>\n",
       "      <td>14</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>28</th>\n",
       "      <td>HIST1H2BK</td>\n",
       "      <td>24</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>29</th>\n",
       "      <td>HIST1H2BO</td>\n",
       "      <td>13</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>30</th>\n",
       "      <td>HIST1H3A</td>\n",
       "      <td>95</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>31</th>\n",
       "      <td>HIST1H3B</td>\n",
       "      <td>363</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>32</th>\n",
       "      <td>HIST1H3C</td>\n",
       "      <td>174</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>33</th>\n",
       "      <td>HIST1H3D</td>\n",
       "      <td>170</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>34</th>\n",
       "      <td>HIST1H3E</td>\n",
       "      <td>136</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>35</th>\n",
       "      <td>HIST1H3F</td>\n",
       "      <td>114</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>36</th>\n",
       "      <td>HIST1H3G</td>\n",
       "      <td>194</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>37</th>\n",
       "      <td>HIST1H3H</td>\n",
       "      <td>130</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>38</th>\n",
       "      <td>HIST1H3I</td>\n",
       "      <td>157</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>39</th>\n",
       "      <td>HIST1H3J</td>\n",
       "      <td>139</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>40</th>\n",
       "      <td>HIST2H3D</td>\n",
       "      <td>23</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>41</th>\n",
       "      <td>HIST3H3</td>\n",
       "      <td>174</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>42</th>\n",
       "      <td>HLA-A</td>\n",
       "      <td>534</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>43</th>\n",
       "      <td>HLA-B</td>\n",
       "      <td>441</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>44</th>\n",
       "      <td>IKBKE</td>\n",
       "      <td>440</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>45</th>\n",
       "      <td>MAP3K14</td>\n",
       "      <td>2</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>46</th>\n",
       "      <td>MDC1-AS1</td>\n",
       "      <td>1</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>47</th>\n",
       "      <td>MEF2BNB-MEF2B</td>\n",
       "      <td>2</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>48</th>\n",
       "      <td>P2RY8</td>\n",
       "      <td>47</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>49</th>\n",
       "      <td>PARK2</td>\n",
       "      <td>574</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>50</th>\n",
       "      <td>RFWD2</td>\n",
       "      <td>519</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>51</th>\n",
       "      <td>RP1-85F18.6</td>\n",
       "      <td>1</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>52</th>\n",
       "      <td>RP11-461L13.2</td>\n",
       "      <td>1</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>53</th>\n",
       "      <td>RP11-513D5.2</td>\n",
       "      <td>1</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>54</th>\n",
       "      <td>RPS6KA4</td>\n",
       "      <td>669</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>55</th>\n",
       "      <td>RYBP</td>\n",
       "      <td>171</td>\n",
       "    </tr>\n",
       "  </tbody>\n",
       "</table>\n",
       "</div>"
      ],
      "text/plain": [
       "             gene  num mutations\n",
       "0      AC004906.3              1\n",
       "1      AC008738.1              6\n",
       "2     AP003419.16              1\n",
       "3        C1orf147              4\n",
       "4            CD58             80\n",
       "5   CTD-2278I10.6              1\n",
       "6    CTD-2330K9.2              1\n",
       "7   CTD-2540B15.7              1\n",
       "8   CTD-2561B21.3              1\n",
       "9         FAM175A            192\n",
       "10         FAM46C            298\n",
       "11         FAM58A            179\n",
       "12          GTF2I              3\n",
       "13          H3F3A            135\n",
       "14          H3F3B            113\n",
       "15          H3F3C            224\n",
       "16       HIST1H1B             62\n",
       "17       HIST1H1C            487\n",
       "18       HIST1H1D             70\n",
       "19       HIST1H1E            227\n",
       "20      HIST1H2AC             35\n",
       "21      HIST1H2AG             29\n",
       "22      HIST1H2AL              9\n",
       "23      HIST1H2AM             44\n",
       "24      HIST1H2BC             31\n",
       "25      HIST1H2BD            183\n",
       "26      HIST1H2BG             22\n",
       "27      HIST1H2BJ             14\n",
       "28      HIST1H2BK             24\n",
       "29      HIST1H2BO             13\n",
       "30       HIST1H3A             95\n",
       "31       HIST1H3B            363\n",
       "32       HIST1H3C            174\n",
       "33       HIST1H3D            170\n",
       "34       HIST1H3E            136\n",
       "35       HIST1H3F            114\n",
       "36       HIST1H3G            194\n",
       "37       HIST1H3H            130\n",
       "38       HIST1H3I            157\n",
       "39       HIST1H3J            139\n",
       "40       HIST2H3D             23\n",
       "41        HIST3H3            174\n",
       "42          HLA-A            534\n",
       "43          HLA-B            441\n",
       "44          IKBKE            440\n",
       "45        MAP3K14              2\n",
       "46       MDC1-AS1              1\n",
       "47  MEF2BNB-MEF2B              2\n",
       "48          P2RY8             47\n",
       "49          PARK2            574\n",
       "50          RFWD2            519\n",
       "51    RP1-85F18.6              1\n",
       "52  RP11-461L13.2              1\n",
       "53   RP11-513D5.2              1\n",
       "54        RPS6KA4            669\n",
       "55           RYBP            171"
      ]
     },
     "execution_count": 33,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "excluded = pd.DataFrame(excluded_genes, columns=['gene'])\n",
    "excluded['num mutations']= num_excluded\n",
    "excluded"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "## Example: mapping from sequence to codon"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 27,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "(array([1]), array([2]))"
      ]
     },
     "execution_count": 27,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "i=0\n",
    "codon_locs = human_codon_locations[i]\n",
    "codon_seqs = human_codon_seqs[i]\n",
    "aa = human_aa[i]\n",
    "\n",
    "\n",
    "ind = np.where(np.array(codon_locs) == 133710839)\n",
    "ind"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 28,
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "TTG\n",
      "G\n",
      "L\n"
     ]
    }
   ],
   "source": [
    "#located in 2nd codon (index=1) and 3rd place in codon (index=2)\n",
    "codon_num = ind[0][0]\n",
    "seq_index_in_codon = ind[1][0]#ranges from 0,1,or 2\n",
    "print(codon_seqs[codon_num])\n",
    "print(codon_seqs[codon_num][seq_index_in_codon])\n",
    "print(aa[codon_num])\n",
    "\n"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 34,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/html": [
       "<div>\n",
       "<style scoped>\n",
       "    .dataframe tbody tr th:only-of-type {\n",
       "        vertical-align: middle;\n",
       "    }\n",
       "\n",
       "    .dataframe tbody tr th {\n",
       "        vertical-align: top;\n",
       "    }\n",
       "\n",
       "    .dataframe thead th {\n",
       "        text-align: right;\n",
       "    }\n",
       "</style>\n",
       "<table border=\"1\" class=\"dataframe\">\n",
       "  <thead>\n",
       "    <tr style=\"text-align: right;\">\n",
       "      <th></th>\n",
       "      <th>Hugo_Symbol</th>\n",
       "      <th>Entrez_Gene_Id</th>\n",
       "      <th>Center</th>\n",
       "      <th>NCBI_Build</th>\n",
       "      <th>Chromosome</th>\n",
       "      <th>Start_Position</th>\n",
       "      <th>End_Position</th>\n",
       "      <th>Strand</th>\n",
       "      <th>Consequence</th>\n",
       "      <th>Variant_Classification</th>\n",
       "      <th>...</th>\n",
       "      <th>VARIANT_CLASS</th>\n",
       "      <th>all_effects</th>\n",
       "      <th>amino_acid_change</th>\n",
       "      <th>cDNA_Change</th>\n",
       "      <th>cDNA_position</th>\n",
       "      <th>cdna_change</th>\n",
       "      <th>comments</th>\n",
       "      <th>n_depth</th>\n",
       "      <th>t_depth</th>\n",
       "      <th>transcript</th>\n",
       "    </tr>\n",
       "  </thead>\n",
       "  <tbody>\n",
       "    <tr>\n",
       "      <th>0</th>\n",
       "      <td>BRCA2</td>\n",
       "      <td>675</td>\n",
       "      <td>MSKCC</td>\n",
       "      <td>GRCh37</td>\n",
       "      <td>13</td>\n",
       "      <td>32937315</td>\n",
       "      <td>32937315</td>\n",
       "      <td>+</td>\n",
       "      <td>splice_acceptor_variant</td>\n",
       "      <td>Splice_Site</td>\n",
       "      <td>...</td>\n",
       "      <td>NaN</td>\n",
       "      <td>NaN</td>\n",
       "      <td>NaN</td>\n",
       "      <td>NaN</td>\n",
       "      <td>NaN</td>\n",
       "      <td>NaN</td>\n",
       "      <td>NaN</td>\n",
       "      <td>NaN</td>\n",
       "      <td>NaN</td>\n",
       "      <td>NaN</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>1</th>\n",
       "      <td>BRCA2</td>\n",
       "      <td>0</td>\n",
       "      <td>MSKCC</td>\n",
       "      <td>37</td>\n",
       "      <td>13</td>\n",
       "      <td>32914437</td>\n",
       "      <td>32914438</td>\n",
       "      <td>+</td>\n",
       "      <td>NaN</td>\n",
       "      <td>NaN</td>\n",
       "      <td>...</td>\n",
       "      <td>NaN</td>\n",
       "      <td>NaN</td>\n",
       "      <td>NaN</td>\n",
       "      <td>NaN</td>\n",
       "      <td>NaN</td>\n",
       "      <td>NaN</td>\n",
       "      <td>NaN</td>\n",
       "      <td>NaN</td>\n",
       "      <td>NaN</td>\n",
       "      <td>NaN</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>2</th>\n",
       "      <td>MUTYH</td>\n",
       "      <td>4595</td>\n",
       "      <td>MSKCC</td>\n",
       "      <td>GRCh37</td>\n",
       "      <td>1</td>\n",
       "      <td>45798475</td>\n",
       "      <td>45798475</td>\n",
       "      <td>+</td>\n",
       "      <td>missense_variant</td>\n",
       "      <td>Missense_Mutation</td>\n",
       "      <td>...</td>\n",
       "      <td>NaN</td>\n",
       "      <td>NaN</td>\n",
       "      <td>NaN</td>\n",
       "      <td>NaN</td>\n",
       "      <td>NaN</td>\n",
       "      <td>NaN</td>\n",
       "      <td>NaN</td>\n",
       "      <td>NaN</td>\n",
       "      <td>NaN</td>\n",
       "      <td>NaN</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>3</th>\n",
       "      <td>BRCA2</td>\n",
       "      <td>675</td>\n",
       "      <td>MSKCC</td>\n",
       "      <td>GRCh37</td>\n",
       "      <td>13</td>\n",
       "      <td>32893302</td>\n",
       "      <td>32893302</td>\n",
       "      <td>+</td>\n",
       "      <td>frameshift_variant</td>\n",
       "      <td>Frame_Shift_Ins</td>\n",
       "      <td>...</td>\n",
       "      <td>NaN</td>\n",
       "      <td>NaN</td>\n",
       "      <td>NaN</td>\n",
       "      <td>NaN</td>\n",
       "      <td>NaN</td>\n",
       "      <td>NaN</td>\n",
       "      <td>NaN</td>\n",
       "      <td>NaN</td>\n",
       "      <td>NaN</td>\n",
       "      <td>NaN</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>4</th>\n",
       "      <td>BRCA1</td>\n",
       "      <td>0</td>\n",
       "      <td>MSKCC</td>\n",
       "      <td>37</td>\n",
       "      <td>17</td>\n",
       "      <td>41251824</td>\n",
       "      <td>41251825</td>\n",
       "      <td>+</td>\n",
       "      <td>NaN</td>\n",
       "      <td>NaN</td>\n",
       "      <td>...</td>\n",
       "      <td>NaN</td>\n",
       "      <td>NaN</td>\n",
       "      <td>NaN</td>\n",
       "      <td>NaN</td>\n",
       "      <td>NaN</td>\n",
       "      <td>NaN</td>\n",
       "      <td>NaN</td>\n",
       "      <td>NaN</td>\n",
       "      <td>NaN</td>\n",
       "      <td>NaN</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>...</th>\n",
       "      <td>...</td>\n",
       "      <td>...</td>\n",
       "      <td>...</td>\n",
       "      <td>...</td>\n",
       "      <td>...</td>\n",
       "      <td>...</td>\n",
       "      <td>...</td>\n",
       "      <td>...</td>\n",
       "      <td>...</td>\n",
       "      <td>...</td>\n",
       "      <td>...</td>\n",
       "      <td>...</td>\n",
       "      <td>...</td>\n",
       "      <td>...</td>\n",
       "      <td>...</td>\n",
       "      <td>...</td>\n",
       "      <td>...</td>\n",
       "      <td>...</td>\n",
       "      <td>...</td>\n",
       "      <td>...</td>\n",
       "      <td>...</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>422817</th>\n",
       "      <td>SMARCA4</td>\n",
       "      <td>6597</td>\n",
       "      <td>MSKCC</td>\n",
       "      <td>GRCh37</td>\n",
       "      <td>19</td>\n",
       "      <td>11144132</td>\n",
       "      <td>11144132</td>\n",
       "      <td>+</td>\n",
       "      <td>missense_variant</td>\n",
       "      <td>Missense_Mutation</td>\n",
       "      <td>...</td>\n",
       "      <td>NaN</td>\n",
       "      <td>NaN</td>\n",
       "      <td>NaN</td>\n",
       "      <td>NaN</td>\n",
       "      <td>NaN</td>\n",
       "      <td>NaN</td>\n",
       "      <td>NaN</td>\n",
       "      <td>NaN</td>\n",
       "      <td>NaN</td>\n",
       "      <td>NaN</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>422818</th>\n",
       "      <td>BRAF</td>\n",
       "      <td>673</td>\n",
       "      <td>MSKCC</td>\n",
       "      <td>GRCh37</td>\n",
       "      <td>7</td>\n",
       "      <td>140453149</td>\n",
       "      <td>140453149</td>\n",
       "      <td>+</td>\n",
       "      <td>missense_variant</td>\n",
       "      <td>Missense_Mutation</td>\n",
       "      <td>...</td>\n",
       "      <td>NaN</td>\n",
       "      <td>NaN</td>\n",
       "      <td>NaN</td>\n",
       "      <td>NaN</td>\n",
       "      <td>NaN</td>\n",
       "      <td>NaN</td>\n",
       "      <td>NaN</td>\n",
       "      <td>NaN</td>\n",
       "      <td>NaN</td>\n",
       "      <td>NaN</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>422819</th>\n",
       "      <td>NRAS</td>\n",
       "      <td>4893</td>\n",
       "      <td>MSKCC</td>\n",
       "      <td>GRCh37</td>\n",
       "      <td>1</td>\n",
       "      <td>115258747</td>\n",
       "      <td>115258747</td>\n",
       "      <td>+</td>\n",
       "      <td>missense_variant</td>\n",
       "      <td>Missense_Mutation</td>\n",
       "      <td>...</td>\n",
       "      <td>NaN</td>\n",
       "      <td>NaN</td>\n",
       "      <td>NaN</td>\n",
       "      <td>NaN</td>\n",
       "      <td>NaN</td>\n",
       "      <td>NaN</td>\n",
       "      <td>NaN</td>\n",
       "      <td>NaN</td>\n",
       "      <td>NaN</td>\n",
       "      <td>NaN</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>422820</th>\n",
       "      <td>TERT</td>\n",
       "      <td>7015</td>\n",
       "      <td>MSKCC</td>\n",
       "      <td>GRCh37</td>\n",
       "      <td>5</td>\n",
       "      <td>1295521</td>\n",
       "      <td>1295521</td>\n",
       "      <td>+</td>\n",
       "      <td>upstream_gene_variant</td>\n",
       "      <td>5'Flank</td>\n",
       "      <td>...</td>\n",
       "      <td>NaN</td>\n",
       "      <td>NaN</td>\n",
       "      <td>NaN</td>\n",
       "      <td>NaN</td>\n",
       "      <td>NaN</td>\n",
       "      <td>NaN</td>\n",
       "      <td>NaN</td>\n",
       "      <td>NaN</td>\n",
       "      <td>NaN</td>\n",
       "      <td>NaN</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>422821</th>\n",
       "      <td>KRAS</td>\n",
       "      <td>3845</td>\n",
       "      <td>MSKCC</td>\n",
       "      <td>GRCh37</td>\n",
       "      <td>12</td>\n",
       "      <td>25398284</td>\n",
       "      <td>25398284</td>\n",
       "      <td>+</td>\n",
       "      <td>missense_variant</td>\n",
       "      <td>Missense_Mutation</td>\n",
       "      <td>...</td>\n",
       "      <td>NaN</td>\n",
       "      <td>NaN</td>\n",
       "      <td>NaN</td>\n",
       "      <td>NaN</td>\n",
       "      <td>NaN</td>\n",
       "      <td>NaN</td>\n",
       "      <td>NaN</td>\n",
       "      <td>NaN</td>\n",
       "      <td>NaN</td>\n",
       "      <td>NaN</td>\n",
       "    </tr>\n",
       "  </tbody>\n",
       "</table>\n",
       "<p>422822 rows × 123 columns</p>\n",
       "</div>"
      ],
      "text/plain": [
       "       Hugo_Symbol  Entrez_Gene_Id Center NCBI_Build Chromosome  \\\n",
       "0            BRCA2             675  MSKCC     GRCh37         13   \n",
       "1            BRCA2               0  MSKCC         37         13   \n",
       "2            MUTYH            4595  MSKCC     GRCh37          1   \n",
       "3            BRCA2             675  MSKCC     GRCh37         13   \n",
       "4            BRCA1               0  MSKCC         37         17   \n",
       "...            ...             ...    ...        ...        ...   \n",
       "422817     SMARCA4            6597  MSKCC     GRCh37         19   \n",
       "422818        BRAF             673  MSKCC     GRCh37          7   \n",
       "422819        NRAS            4893  MSKCC     GRCh37          1   \n",
       "422820        TERT            7015  MSKCC     GRCh37          5   \n",
       "422821        KRAS            3845  MSKCC     GRCh37         12   \n",
       "\n",
       "        Start_Position  End_Position Strand              Consequence  \\\n",
       "0             32937315      32937315      +  splice_acceptor_variant   \n",
       "1             32914437      32914438      +                      NaN   \n",
       "2             45798475      45798475      +         missense_variant   \n",
       "3             32893302      32893302      +       frameshift_variant   \n",
       "4             41251824      41251825      +                      NaN   \n",
       "...                ...           ...    ...                      ...   \n",
       "422817        11144132      11144132      +         missense_variant   \n",
       "422818       140453149     140453149      +         missense_variant   \n",
       "422819       115258747     115258747      +         missense_variant   \n",
       "422820         1295521       1295521      +    upstream_gene_variant   \n",
       "422821        25398284      25398284      +         missense_variant   \n",
       "\n",
       "       Variant_Classification  ... VARIANT_CLASS all_effects  \\\n",
       "0                 Splice_Site  ...           NaN         NaN   \n",
       "1                         NaN  ...           NaN         NaN   \n",
       "2           Missense_Mutation  ...           NaN         NaN   \n",
       "3             Frame_Shift_Ins  ...           NaN         NaN   \n",
       "4                         NaN  ...           NaN         NaN   \n",
       "...                       ...  ...           ...         ...   \n",
       "422817      Missense_Mutation  ...           NaN         NaN   \n",
       "422818      Missense_Mutation  ...           NaN         NaN   \n",
       "422819      Missense_Mutation  ...           NaN         NaN   \n",
       "422820                5'Flank  ...           NaN         NaN   \n",
       "422821      Missense_Mutation  ...           NaN         NaN   \n",
       "\n",
       "       amino_acid_change cDNA_Change cDNA_position  cdna_change comments  \\\n",
       "0                    NaN         NaN           NaN          NaN      NaN   \n",
       "1                    NaN         NaN           NaN          NaN      NaN   \n",
       "2                    NaN         NaN           NaN          NaN      NaN   \n",
       "3                    NaN         NaN           NaN          NaN      NaN   \n",
       "4                    NaN         NaN           NaN          NaN      NaN   \n",
       "...                  ...         ...           ...          ...      ...   \n",
       "422817               NaN         NaN           NaN          NaN      NaN   \n",
       "422818               NaN         NaN           NaN          NaN      NaN   \n",
       "422819               NaN         NaN           NaN          NaN      NaN   \n",
       "422820               NaN         NaN           NaN          NaN      NaN   \n",
       "422821               NaN         NaN           NaN          NaN      NaN   \n",
       "\n",
       "        n_depth  t_depth  transcript  \n",
       "0           NaN      NaN         NaN  \n",
       "1           NaN      NaN         NaN  \n",
       "2           NaN      NaN         NaN  \n",
       "3           NaN      NaN         NaN  \n",
       "4           NaN      NaN         NaN  \n",
       "...         ...      ...         ...  \n",
       "422817      NaN      NaN         NaN  \n",
       "422818      NaN      NaN         NaN  \n",
       "422819      NaN      NaN         NaN  \n",
       "422820      NaN      NaN         NaN  \n",
       "422821      NaN      NaN         NaN  \n",
       "\n",
       "[422822 rows x 123 columns]"
      ]
     },
     "execution_count": 34,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "impact_data.iloc[[0]]"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {},
   "outputs": [],
   "source": []
  }
 ],
 "metadata": {
  "kernelspec": {
   "display_name": "Python 3",
   "language": "python",
   "name": "python3"
  },
  "language_info": {
   "codemirror_mode": {
    "name": "ipython",
    "version": 3
   },
   "file_extension": ".py",
   "mimetype": "text/x-python",
   "name": "python",
   "nbconvert_exporter": "python",
   "pygments_lexer": "ipython3",
   "version": "3.7.1"
  },
  "toc": {
   "base_numbering": 1,
   "nav_menu": {
    "height": "261.26837158203125px",
    "width": "551.635986328125px"
   },
   "number_sections": true,
   "sideBar": true,
   "skip_h1_title": false,
   "title_cell": "Table of Contents",
   "title_sidebar": "Contents",
   "toc_cell": false,
   "toc_position": {},
   "toc_section_display": true,
   "toc_window_display": true
  }
 },
 "nbformat": 4,
 "nbformat_minor": 2
}
